Hello,
I am building a swift macOS app and have noticed issues today with delivering APN's to both development and production devices. Similar to this thread the only way I can get them to deliver temporarily is to do one of:
Change the bundle ID of my app to a new bundle ID, then start it up. I will usually get the first notification.
Reset my network (either wired ethernet or wifi, typically both)
Using the push notifications console for development sends, I see the message "discarded as device was offline" in the delivery log even though the device is still online and was just registered when I got back the deviceToken.
If I set an expiration on development notifications then the delivery log says "stored for device power considerations" and the notification will then send once I do one of the above steps (new bundle or reset network).
Previous to today the notifications were sending immediately and I had no issues getting them. Is there something I can do to fix this problem, is it a problem with the APN provider, or is it something else I haven't thought of?
A unique ID for an expiration-based notification is 1755def8-1a44-cbcf-c64b-64e435c30f81, and a non-expiry is d7a72b46-0c64-4500-0abc-3734f9efbd90.
User Notifications
RSS for tagPush user-facing notifications to the user's device from a server or generate them locally from your app using User Notifications.
Posts under User Notifications tag
159 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hi,
I implemented push notifications on my PWA, and it work fine with all browsers except with Safari. I followed all the recommendations given by Brady Eidson in this video :
Meet Web Push for Safari
And the result is that all the push notification process work fine with others browsers, from the subscription to the notification delivery and display. But with Safari the endpoint is always empty and I do not understand why. No error is triggered during subscription. Just the result is a subscription with an empty endpoint.
I have the same result on iPad, iPhone and iMac. Everything is working well with others browsers or with android smartphone. But contrary to what Brady Eidson promised in his video, it does not work with Safari.
Hello!
I am working on an app that requires to send a local push notification to the user from an app extension (from the ShieldActionDelegate to be precise).
This is suggested by DTS as a workaround for this issue: https://forums.developer.apple.com/forums/thread/766644
But now, on the iOS 18.2 beta, local push notifications are delayed by up to 10 seconds, even though the push notification is classified as .timeSensitive, leading to a very bad user experience (where to user has to sit and wait for the notification to arrive without knowing how long it will take).
This only happens when Apple Intelligence is turned on.
This had happened previously on the iOS 18.1 beta but was fixed for the final release: https://forums.developer.apple.com/forums/thread/764848
But now the issue came back on the latest iOS 18.2 beta.
I have documented the new behavior in FB15668616
Any help is appreciated!
I need to implement push notifications in Safari. I already have a web app that can be added to the home screen.
When researching push notifications in Safari, one of the things I found was that you don't need to be part of the Apple Developer Program to use this feature (text here).
But when checking the requirements within the platforms, such as Pusher, they require a type of certificate that can only be generated with a paid account, that is, I need to participate in the Apple Developer Program.
Pusher documentation: https://pusher.com/docs/beams/getting-started/web/configure-safari/
Now, I have many questions:
Do I really need a paid account to issue the certificate?
Can I issue the certificate via the web or only on a Mac?
Do I really need this certificate?
I am developing an app which makes use of actionable notifications.
On my code (the func userNotificationCenter function), I need to read my users from the local storage on the iPhone:
let query: [String: Any] = [
kSecAttrService as String: "uio-auth",
kSecAttrAccount as String: "users",
kSecClass as String: kSecClassGenericPassword,
kSecReturnData as String: true
]
var result: AnyObject?
SecItemCopyMatching(query as CFDictionary, &result)
let ref = result as? Data
But when the same code execute when I tap on the notification on the Apple Watch, it doesn't fetch anything. It now occurs to to me:
Does it mean that when an actionable notification programmed for the iOS is displayed on the Apple Watch, it tries to access its own storage, and not the iPhone? If so, is there a nice way to pass the values to the watchOS so that when the callback for the actionable notifications run, it has then the data it needs?
Wake up this morning and see this very concerning sticky message in Notification Center:
bash was prevented from modifying apps
It didn't say what parent program called `bash' so I clicked on the N.C. message to see if there was more information and it just disappeared (as if I had chosen to click on the X to clear the message-I wish I had taken a screenshot first). I have already sent in a request to Apple for them to give more detailed information on events like this. If there is an existing threat on a device it needs to be removed.
The only thing that I know of that happened overnight was a SPAM email from "Norton Antivirus" came into my Gmail Inbox that wasn't filtered as SPAM and macOS announced it in Notification Center. I don't see anything funny in the RAW data of the email - and reported it to spamcop.
Is it possible that a malicious email could contain html code that runs when it's announced via macOS Notification Center?
I am using a Key to connect my notification server with APNS in order to send out notifications to users. I have recently added notifications to a second app of mine, using the same notification server to fire off notifications for both apps. However, any notifications going to the second app return the error InvalidProviderToken, where as I get no such issues when send notifications to the first app. Everything, including the payloads, are exactly the same between the two apps, the only difference is that the device IDs are attached to different apps.
Does anyone know why/how this would happen and how I can resolve it?
Hey there, i created a independent Watch OS app and I configure push notification there.
so on watch simulator I am able to get push notification every time.
but today I test watch app to my real watch series 6 WatchOS 11.
I got the permission alert I allowed it, and I am able to get the device token as well now if I try to send push notification to my real watch app I get this logs.
Oct 22, 2024, 11:09:12.024 AM GMT+5
received by APNS Server
Oct 22, 2024, 11:09:12.334 AM GMT+5
discarded as application was not registered
why is that ? is there any body know's ? why i am not receiving remote notification on my real watch instead i get that my application is not register...
I have an iOS and watchOS app where both can run independently, I am not using WatchConnectivity to send data back and fourth. The issue I'm having is that if I schedule a local notification on the watch and the phone is unlocked, it will not show on the watch for about 10-15 seconds. If I uninstall the iOS app or have the phone locked, it will show immediately on the watch.
To my understanding, this is somewhat the expected functionality but is there a way to bypass it? My app is a timer app and it really should not have a delay.
Hi!
I have some unit tests which send and receive local notifications. Unfortunately, when ran on Xcode Cloud, the tests time out. I assume due to a call to requestAuthorization in init() (I have started using Swift Testing).
Is there a way to get around this issue in order to run the tests?
I would like to do exactly this but the API doens't seem to allow it. Was wondering if there were any creative workarounds? Basically, I have a reminder app that needs to send reminders at a certain time each day (there are several of these reminders per day). Each reminder has a couple of follow-ups scheduled at 5 min intervals.
If a user takes action on the task before the reminder is sent however, I would like to unschedule that notification (and follow ups) until the next day. The unscheduling part is easy, but there seems to be no reliable way to re-schedule it for the next day and continue repeating.
Looked into background tasks and they don't seem intended for these purposes nor do they seem reliable. The user isn't guaranteed to take action on notifications nor open the app within a 24-hour period after they have taken action on their task.
With apple intelligence enabled I am seeing a 10-15 sec delay in push notification.
This is actually causing issue with my alarm system, door bells and 2FA requests.
I'm using iPhone 16 Pro.
First installed 18.1 Dev beta 5 and AI and noticed this.
When beta 6 was released it continued.
I put in FB15389900.
My app uses custom notifications with custom images. Why do these images get mixed up with those from other apps, causing my notifications to display images from other apps?
`INImage *avatarImage = [INImage imageWithImageData:imageData];
NSPersonNameComponents *nameComponents = [[NSPersonNameComponents alloc] init];
nameComponents.nickname = content.title;
INPersonHandle *handle = [[INPersonHandle alloc] initWithValue:nil type:INPersonHandleTypeUnknown];
INPerson *messageSender = [[INPerson alloc] initWithPersonHandle:handle
nameComponents:nameComponents
displayName:content.title
image:avatarImage
contactIdentifier:nil
customIdentifier:customIdentifier
isMe:NO
suggestionType:(INPersonSuggestionTypeNone)];
INSpeakableString *speakableString = [[INSpeakableString alloc] initWithSpokenPhrase:content.subtitle.length ? content.subtitle : @""];
INSendMessageIntent *intent = [[INSendMessageIntent alloc] initWithRecipients:@[messageSender]
outgoingMessageType:(INOutgoingMessageTypeOutgoingMessageText)
content:content.body
speakableGroupName:speakableString
conversationIdentifier:identifier
serviceName:nil
sender:messageSender
attachments:nil];
[intent setImage:avatarImage forParameterNamed:@"speakableGroupName"];
INInteraction *interaction = [[INInteraction alloc]initWithIntent:intent response:nil];
interaction.direction = INInteractionDirectionIncoming;
[interaction donateInteractionWithCompletion:nil];
UNNotificationContent *_content = [content contentByUpdatingWithProvider:intent error:nil];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier
content:_content
trigger:trigger];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:completionHandler];`
I want to switch from Apns to standard notificationApi browser notification, but when my website originally used Apns, I switched to standard API and called Notification for message notification. The notification didn't appear.
I confirmed that Notification.permission is granted.
Is there a way to to add a key for imageURL below that shows as image preview on the right side of a push notification or do i need to create a Notification Content Extension to make it work?
`const message = {
apns: {
payload: {
aps: {
'mutable-content': 1,
alert: {
title: title,
body: body,
image: imageURL,
},
},
},
fcm_options: {
image: imageURL,
},
},
data: {
articleId: articleId,
'media-url': imageURL,
},
tokens: tokens,
};`
I'm getting the image through, but just if the user long presses on the push notification and then it appears below, but i want it to look like in the screenshot:
Thanks
Hi
After uploading a problematic version of our app to TestFlight my iphone does not get push notification anymore for our app. Other users are not affected.
I deleted the app and installed the version from the appstore and still i do not get push notifications to the app.
anyone that installed the version on testflight can't get push notification even if they went back to the original version from the app store.
also tried to shutdown / startup the phone... no change.
Any idea what went wrong and how to fix it?
Hi, hope you're all doing well. I have a real brain-cracker here... Have been looking into this for the past 20 hours, but can't figure it out.
We built an iPhone app that essentially functions as a shell around a PWA Web-App using WebView. The tricky part here to set things up was getting the Push Notifications to work. Eventually we got this working though (with help of Firebase), and the app has been working great for the past 7 months. Now, all of a sudden as it seems, when users first open up the app, there's no FCM token generated and passed on to the WebView instance running javascript. Or at least, the listening event ('push-token') no longer gets fired.
Users who already have their FCM token generated and stored earlier on, receive push notifications without any issues. It's just that no new FCM tokens seem to be generated - or at least no longer passed to the WebView's javascript code. I know this for a fact as my tests turn out that the following event (present in my PWA Web-App JS code) no longer gets fired. Again, this worked fine before. I have NOT updated the native app since 6-7 months.
`/* LISTEN FOR FCM (PUSH MESSAGES) TOKEN FROM NATIVE (IOS) SHELL: */
window.addEventListener('push-token', function(event) {
//alert("Push Token registration event called from native shell");
if (event && event.detail) {
var token = event.detail;
window.fcmPushMessageToken = token;
localStorage.setItem('fcmPushMessageToken', token);
//alert("Received FCM token: " + token);
registerDeviceForPushMessages();
}
});`
Hereé the part in my native iOS code that used to call this event from within the native iOS shell:
func handleFCMToken(){
DispatchQueue.main.async(execute: {
Messaging.messaging().token { token, error in
if let error = error {
print("Error fetching FCM registration token: \(error)")
checkViewAndEvaluate(event: "push-token", detail: "ERROR GET TOKEN")
} else if let token = token {
print("FCM registration token: \(token)")
checkViewAndEvaluate(event: "push-token", detail: "'\(token)'")
}
}
})
}
func checkViewAndEvaluate(event: String, detail: String) {
if (!EPDriversApp2.WebView.isHidden && !EPDriversApp2.WebView.isLoading ) {
DispatchQueue.main.async(execute: {
EPDriversApp2.WebView.evaluateJavaScript("this.dispatchEvent(new CustomEvent('\(event)', { detail: \(detail) }))")
})
}
else {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
checkViewAndEvaluate(event: event, detail: detail)
}
}
}
Again, I have not updated the native iOS app OR the WebApp's code. This just stopped functioning all of a sudden.
One "weird" thing I noticed that there's no Provisiong Profile associated with the app. I'm not sure whether this was ever the case before, to be honest. Is this even mandatory? Can not having a Provisiong Profile associated with the app effect the ability of an already pusblished app for generating Push Notification tokens?
I'm scheduling local notifications on my WatchOS app, but they are always alerting exactly 13 seconds later than scheduled. I have read other users having the exact same issue but there is no solution anywhere. I'm not sure how one is supposed to write any sort of timer app when they are always coming in delayed. Any idea why this occurs and how to resolve it? For now I am subtracting 13 seconds from the end time, but that's not really a solution I'm happy with.
Thanks
I created a local notification as follows:
func scheduleNotification(title: String, subtitle: String = "", date: Date, id: String) {
// Extract the components from the date
let calendar = Calendar.current
let hour = calendar.component(.hour, from: date)
let minute = calendar.component(.minute, from: date)
let second = calendar.component(.second, from: date)
// Set the extracted components into DateComponents
var dateComponents = DateComponents()
dateComponents.hour = hour
dateComponents.minute = minute
dateComponents.second = second
let content = UNMutableNotificationContent()
content.title = title
content.subtitle = subtitle
content.sound = UNNotificationSound.default
let action1 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_1.label, options: [])
let action2 = UNNotificationAction(identifier: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.id, title: Constants.NOTIFICATION_ACTION_IDENTIFIER_2.label, options: [])
let category = UNNotificationCategory(identifier: "reminderCategory", actions: [action1, action2], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
content.categoryIdentifier = "reminderCategory"
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)
// add our notification request
UNUserNotificationCenter.current().add(request)
}
and I also have
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// Handle foreground presentation options
completionHandler([.sound, .badge])
}
but for some reason the notification only shown on the phone. I've made sure that the phone is locked, apple watch is unlocked and also the notification setting in the watch app for this app is set to mirror.
We are recently started the migration from Certificate based approach push notification configuration to Token bases (APNS Keys) approach push notifications.
From Server side, its pretty straight forward that we need to use APNS Keys.
But We are facing one issue where we are not sure whether we can expire the existing push notification certificate that we are using so far or not.
If I expire the existing certificate, then it will also be removed from App Id configuration capabilities as shown below and when I create the provisioning profile for this Bundle Id, it doesn't contain the push notification capability and also shows error in the Xcode while using the profile.
can anyone help on this how to resolve this issue ? or any process or steps to follow for this migration ?
Thanks in advance.