Send push notifications to Mac, iOS, iPadOS, tvOS devices through your app using the Apple Push Notifications service (APNs).

Posts under APNS tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Notification Service Extension not getting invoked in macOS
I have created a Notification service extension as target to the main MacOS application. I want to update the content of my remote notification using this extension but due to some reason the extension is not getting invoked to update my remote notification. The auto execution of the below method seems to fail for my app extension. didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) I have tried the suggested solutions in this link but it did not help. Maybe there are some differences to using Notification service for MacOS and ios that I m not aware. I am able to send normal remote notifications using the curl command, but it is not invoking the notification service extension. Below is the curl command. curl -v --header "apns-topic: $TOPIC" --header "apns-push-type: alert" --header "authorization: bearer $AUTHENTICATION_TOKEN" --data '{"aps": {"mutable-content": 1,"alert": {"title": "Encrypted title","body": "Encrypted body"}},"MEETING_ORGANIZER": "MyMeet"}' --http2 https://${APNS_HOST_NAME}/3/device/${DEVICE_TOKEN} Is there anything I m missing that is causing this problem?
0
0
408
Aug ’23
Xcode Cloud overwriting apns-environment entitlement
I have recently moved our CI/CD pipeline to using xcode cloud. Everything has been going great until we tried to test our VoIP pushes in our test environment. In our old system, our entitlements file set the apns-environment to develop, so when we distributed an archived build to our QA team, it would generate sandbox APNS device tokens for testing. But since I have switched to xcode cloud, it looks to be generate production apns device tokens now, so all of our sandbox pushes are failing to send. Is there a way I can make sure xcode cloud send builds that have the apns-environment set to development?
0
0
365
Aug ’23
Swift iOS notification sound problems
I'm currently working on a Swift project for an iOS app that involves receiving notifications. The app is designed to play different sounds based on a specific parameter when a notification arrives. The correct behavior to follow is as follows. There are two types of notifications in the project: start notifications and stop notifications. Once the app receives a start notification it starts an audio player, the audio lasts X seconds but is looped by the player so it potentially lasts forever. When the app receives the stop notification, the player stops and the sound stops. This works great when the app is in the foreground. When the phone is locked and therefore the app is closed, the sound that is heard is X seconds without the sound being repeated as it happens in the foreground. Furthermore, it often happens that when the stop notification arrives, the player does not stop and continues until the end of X s time. Does anyone have an idea of ​​how to put the loop to the sound of the notification with the phone locked and be sure that when the stop notification arrives the player stops? The sound stop works well on some devices while on others it doesn't even with the same iOS versions.
0
0
530
Aug ’23
The most advanced spyware in the world
I have been researching and enduring the most unbelievable attack you have ever heard of. You won't believe me. AT&T doesn't. Apple doesn't. They have not bothered to even take a look. I have multiple screen videos and screenshots that prove that when my phone was stolen, damaged, then returned, it was infected with a very resilient virus of some sort, so that it has been cloned and is duplicated on a MAC. Now the WiFi network I use is likely the jumping off point, but I am not familiar with this level of invasion. I have restored the phone but I have not deleted the E-Sim. And I always restored from a backup. Well once. I did not and still no change. I am not a neophyte, and while I have limited knowledge of the apple code, swift or Xcode or whatever, I do have some coding knowledge from other platforms. One thing I do know though is my iPhone. I bought the first one in 2007 and watched the keynote announcing the App Store on the first iPhone. I know when it is operating as it should. For instance, whenever I reset my google password which is often, or I just look through the google account at devices, this iPhone 14 {Plus running iOS 17 is always listed as a MAC OS X from another region. Sometimes I can see this phone on there as well but it is never the (device I am using). Also, I have screen videos of very strange errors, like certain options will be shut off. Like right now I cannot turn on voice assist. During the damage when it was stolen, the Face ID was damaged. Just now it suddenly got brighter and it does that often almost as often as the volume suddenly going up. My contacts are constantly deleted and that is not because of switching accounts. As this has been occurring four over 4 months now, I have tirelessly investigated every explanation for the errors. I know it is a mac connected to the same WiFi because occasionally the font will change in size and small part of text will be highlighted and it is much smaller than the display of the phone. Everytime I login to Apple ID the password has been changed and this is with 2FA on. Also I just checked yesterday to see, on the AT&T website, and my number in just one day has (5Text messages listed that I did not get. My roommates seem to know things about me I haven't told them. At&T sent me a bill for a different number without a phone connected to it. I use an ESim. I have endless more details and screenshots and I cannot seem to get a response from apple, but my belongings have been stolen, my identity stolen, and my sanity also taken away. You begin to question reality, but just going over my body of evidence is enough to show I have something going on. I want to report this to someone but I would like to maybe get some info on how I could be sure, what is happening? MY Crash reports show interesting stuff. I am actually going to check and make sure the imei numbers in those reports match the device. But please help . This is like super high tech invisible terrorizing spyware and it will be worse for the next person. I mean when I unlock my phone it is never opened to the app I closed it on. NEVER. Email johnmichaelpowers@yahoo.com
1
0
779
Sep ’23
Changing the APNS deviceToken when reinstalling the application
Good day! We use the func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) to get the deviceToken. But when reinstalling the application, we get a new token every time. At the same time, the old tokens remain "alive" and when trying to send a message, they do not return "bad_device_token", the code 200 is returned. {"StatusCode":200,"Reason":"","ApnsID":"fc9b2cff-a0aa-40fe-8d1e-3d1edec0eeb6","Timestamp":"0001-01-01T00:00:00Z"} Why can this happen? This is important for us, because rows from the "device" table are deleted only when we receive "bad_device_token". Thus, the number of devices in the table is constantly growing.
1
1
333
Sep ’23
User Notifications Delayed on Watch
Hi, when sending notifications either via APNS remotely or locally on watchOS, they are delivered with a small but significant delay of ~12 to 20s. That doesn't sound like much, but when e.g. the notification is read on AirPods by Siri via the iOS companion app on the phone it's quite annoying having to wait for the long-look notification UI to appear on the watch to e.g. send a quick reaction. Interesting: If the watch is not connected to the phone, notifications are delivered as quick as on the iPhone (<1s delay). That makes me think that this behavior must be related to the notification forwarding feature as described here https://developer.apple.com/documentation/watchos-apps/enabling-and-receiving-notifications . For a "Dependent watchOS app with an iOS app" it is stated that "You can either send the notification just to iPhone, or send it to both devices. In either case, the system ensures that the user only receives one notification at the best destination." So the watch must somehow coordinate with the iPhone to not show a notification if the "same" (same APNS collapse id?) notification is delivered to the phone as well (?). Is there a way to disable this behavior? Thanks! Quirin
2
0
901
Sep ’23
Push token change on app upgrade
Our app has some Crashlytics & Localytics reporting to collect metrics for diagnostic and info gathering. One thing I'm noticing recently is that if a user has version m of the app installed and updates to version m+1, then for some users, the app has detected and reported that the push token obtained with version m+1 is different from that of version m (for the same handset). That's fine - if the app has detected the change to the token it can send the new one to the server so the server can update. But my question is - if the user didn't explicitly launch the app and thus present the app with the chance to send the new token to the server, then what will happen to the pushes sent by the server using the old token? Presumably they won't get delivered if the token has changed, but if the user has no need to launch the app then they're never going to receive any pushes from the server until they do launch the app. However there's not necessarily any reason why a user should repeatedly launch an app once it's been set up (depending upon what it does and how it delivers info to the user and how the user interacts with it, there's no reason why a user should have to launch the app after initial installation and launch). If so then this seems like a gap in the design of push notifications? If they can change on the same handset, or another scenario is the user backs up their device to iCloud and then restores to a different handset, then in that case the push tokens will have definitely changed, yet any apps using push don't get the chance to send the new token to the server until the user launches the app, meanwhile all pushes from the server will be dropped.
1
0
598
Sep ’23
Not receiving response from APN server while sending push notifications
Hi, I am currently using the token based protocol to send iOS push notifications to users via my application. However, there are several instances when I receive no response from the APN server and as a result the notification is not sent. For the configuration that I am relying on, I am still able to send notifications to other devices. Kindly provide assistance on how to resolve this.
1
0
327
Sep ’23
Cannot create signature for JWT for APNs
I am trying to generate the signature for a JWT using a .p8 private key from Apple for APNs in PHP. If I try to use the following command hash_hmac('sha256', $header . '.' . $payload, $key), when checking it in Apple's JSON Web Token Validator, I get that the signature is invalid. I have also tried converting the .p8 private key to a PEM file and importing it into the OpenSSL library, but I am still getting the error message openssl_sign(): Supplied key param cannot be coerced into a private key. But I generate the JWT using Apple's JSON Web Token Generator, everything goes well, even the request to APNs. Thank you in advance!
1
0
648
Sep ’23
getting TooManyProviderTokenUpdates error in production for applet wallet notifications
Hi All, Product information Our product create and update apple wallet passes per client. For example, client A will have a passtypeidentifier and devices which download the same will have its devicetoken[pushtoken] registered to our database. Same for other clients as well. We had been using legacy binary protocol-based approach till 2021, and we migrated http2 based APNS API implementation in the same year. But past few months, we are getting TooManyProviderTokenUpdates 429 in the production environment. No such error occurring in our lower environment with the same build. We use separate p8 cert,key and teamId per environment. *Implementation we have total of 5 clients, i.e: 5 pass type identifiers. In our current implementation , we create 5 connections per client. hence 5 oauth token[which refreshes only after 20 mins] are created. As we are sending push notifications to Apple wallet passes, we send apns-id as passtypeidentifier , no payload in the body and uses https://api.push.apple.com/3/devies/[pushtoken] endpoint for sending push notifications. So, each connection will have passtypeidentifier defined in the aps-id and device token sent in the URL. We initially suspected, multiple connection for a team identifier would be an issue. So, in our lower region[never reported this error], we tested a new build which implements 1 single connection for all the clients and one Oauth token is being used. In this approach , pass gets updated on the devices, but no notification banner displayed on the devices. So,we reverted to production build and sent notification to those same devices, we found passes updated and notification banner appeared. We are totally confused with the error message and behavior of APNS. Any suggestions or solution would be appreciated.
1
0
538
Sep ’23
Multiple push notification service
my app using FCM and pushy to deliver notif at the same time, the situation that is happening now is that I am getting two similar notification banners. How do I delete/cancel one of the notification banners when one of them has appeared. How do I handle this on the frontend side? If it is not possible/not recommended, can you please provide documentation from Apple so that it is best to change it on the server side
2
0
879
Sep ’23
APNS TooManyProviderTokenUpdates error
We are building a service that would handle push notification through APNS token authentication implementation. It is a multi-tenant service. We are aware of the fact that sharing same connection would cause TooManyProviderTokenUpdates (429) error. Therefore, we limit each connection pool to one app only. And we are only refreshing the token every 60 minutes. However, we are still running into this error lately. We are running multiple copies of our application simultaneous balance the load. Each one generates a different token. Is this a problem? Is sharing provider tokens across workers the only way to avoid this? Please advice.
0
0
224
Sep ’23
Method didReceiveRemoteNotification not called after device reboot
I'm using FCM and differents version of iOS (the oldest is 15.2) on a SwiftUI app. I'm working with silent notifications and everything works well with notifications. I can manage notification behaviour in foreground, in background and when app is killed. If i launch an fcm like this "to": "/topics/all", "priority": "high", "content_available": true, "data": { "custom_id": 1 } didReceiveRemoteNotification is called and all works well. If i use notification attribute like this "to": "/topics/all", "priority": "high", "content_available": true, "notification": { "body": "Sample body", "title": "Sample title" } "data": { "custom_id": 1 } i see the clickable banner and didReceiveRemoteNotification is also called. I can unistall and reinstll the application, everything still to works. Problem comes when i reboot/restart the device. After reboot, didReceiveRemoteNotification seems not to be called. if i use "notification": { "body": "Sample body", "title": "Sample title" } i see the clickable banner but didReceiveRemoteNotification is not called even after banner click. After reboot, I tried to send fcm keeping close the app, opening for first time by icon and opening for first time by notification banner but nothing change. didReceiveRemoteNotification remains not called. The only way to see didReceiveRemoteNotification already called is unistall and reinstall application. Sometimes it's starts to work again after many hours. It's looks like a strage behaviour. I saw a lot of documentation and topics about similar problems and i tried a lot of things, but nothing seems to solve this problem.
2
0
577
Sep ’23
APN service private keys - dealing with the 2-key limit
In my organization we limit the ability for any production-use private credentials from being used in a developer environment. This creates a challenge with APNs keys due to their apparent intended use being a single key across all apps of the org, with the 2nd allowed key being only for the key rotation use case. One idea I have to satisfy all concerns is to take advantage of the two key limit in a slightly different way: Generate the maximum two keys, and use one for dev environments and one for prod environments (with the key being secured according to our policies so that developers never get to see it). If we need to revoke the prod key at any point, we revoke the dev key, regenerate it and make that one the new prod key. Likewise, once that key is deployed in prod, revoke the old prod key and make that the new dev key. Does this seem like a viable approach? Are there any better ways to achieve a fully isolated setup where the production APNs key doesn't appear on a developer environment?
1
0
607
Sep ’23
After updating to iOS 17, I receive multiple notifications multiple times on my iPhone
When sending notification messages, the Apns package is used to send them. I set only the title and body without any additional settings and sent a notification message, but an error occurred in some iPhone devices where multiple messages with the same content were received. Has anyone experienced something like this? How can this be confirmed and processed to resolve this? This situation occurred in iPhone 12, 12maxpro, 14, and 14pro.
1
2
1.6k
Sep ’23
APNS key for multiple Teams
Hello, I have a question about APNS key usage for different teams. Is Key ID created in https://developer.apple.com/account/resources/authkeys/list is scoped only for that particular Team? Or can I use this Key ID for all Teams in organization? Context: We have problem integrating APNs Auth keys (from different teams). Thank you for your answer
1
0
309
Sep ’23
Push Notifications in Background, How to use URLSession?
From a strategy perspective I use BGAppRefreshTask and BGProcessingTasks, successfully implementing them for events triggered within the client application. But there are certain events that are best triggered from the host, such as when we deploy a new set of vendor or price lists. We are trying to implement this background process using Push Notifications. We have successfully implemented sending APNS notifications from the host and receive this .json message in. application: didReceiveRemoteNotification: fetchCompletionHandler: using this code: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"userInfo - %@", userInfo); switch (application.applicationState) { case UIApplicationStateBackground: { //Check to see if this is a configs file update background notification NSArray *dictKeys = [userInfo allKeys]; BOOL foundConfigs = NO; for (NSString *dk in dictKeys) if ([dk isEqualToString:kCONFIGSVERSION]) foundConfigs = YES; if (foundConfigs) { id configVersion = [userInfo objectForKey:kCONFIGSVERSION]; NSLog(@"AAAppDelegate configVersion - %@", configVersion); if ([ServerUtilities deviceAssociatedWithAccount]) [self.bkSessionManager retrieveAndInstallUpdatedConfigFilesWithVersion:[configVersion integerValue]]; } NSLog(@"AAAppDelegate remote notification handler"); completionHandler(UIBackgroundFetchResultNewData); } break; case UIApplicationStateActive: NSLog(@"AAAppDelegate application is active"); completionHandler(UIBackgroundFetchResultNoData); break; case UIApplicationStateInactive: NSLog(@"AAAppDelegate application is inactive"); completionHandler(UIBackgroundFetchResultNoData); break; default: break; } In the Xcode simulator running on an iPhone XS, we place the application in background and then send the APNS message from the host, receiving this .json message in the userInfo dictionary: userInfo - { "app_version" = "0.1"; aps = { "content-available" = 1; }; "configs_version" = 1; "dev_os" = 13; "os_type" = ios; } Receipt of this notification then triggers the client to initiate URLSession and retrieve the appropriate files from the host in order to update values on the client. As we are seeing inconsistent behavior we suspect that we are not implementing the URLSession properly. When setting up the URLSession should it be configured using: NSURLSessionConfiguration defaultSessionConfiguration or NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: ? This is important to know since using backgroundSession requires us to set up the sessions as download tasks and the defaultSession as data tasks. I have tried various combinations so far without success. Any leads here will help...
1
0
525
Oct ’23
notification issue ios 17
Since my last update on my iPhone I am unable to hear any notification from applications like Nest or Google Home. I have several videocameras that I need notifications and alerts from and the sound that the phone produces is ridiculous for sure will not alert me in any way. Not even vibration is possible to set. This problem needs urgent intervention, I suppose there are millions of users risking burgleries or other problems until it is not fixed.
1
0
709
Oct ’23