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

APNS Documentation

Pinned Posts

Posts under APNS tag

258 Posts
Sort by:
Post not yet marked as solved
2 Replies
2.2k Views
Hello here,I am having issues to connect to 'feedback.push.apple.com:2196' for feedback push notifications. My PHP script has been working perfectly until I have renewed the push notification .pem certificate, but now it gives me this error:PHP Warning: stream_socket_client(): Failed to enable crypto in myscript.php on line 10Fact is: the new certificate works because I am able to send out push notifications to my app users, so, where is the problem??!!Here is the PHP script I am using to connect to the service ( I left out the part working on the returned data which is irrilevant for the connection issue):$passphrase = 'mypw'; $stream_context = stream_context_create(); stream_context_set_option($stream_context, 'ssl', 'local_cert', '/path/to/mycertificate.pem'); stream_context_set_option($stream_context, 'ssl', 'passphrase', $passphrase); $apns = stream_socket_client('ssl://feedback.push.apple.com:2196', $errcode, $errstr, 60, STREAM_CLIENT_CONNECT, $stream_context); if(!$apns) { echo "ERROR $errcode: $errstr\n"; return; } ///Read data here... fclose($apns);Any ideas are very welcome!Thanks to everyone in advance.Fab.
Posted
by
Post not yet marked as solved
4 Replies
3.9k Views
I am trying to implement silent push notification in my application where I need to update some data in the server when silent notification comes. I am using Pushkit and it uses VoIP certificate for silent push notification but the app has been rejectd by Apple saying that "I can't use VoIP" certificate. It seems that apple has rejected it as I don't have any VoIP call functionality in my app. In that case how can I implement silent push notification so that my app gets activated even if it is not runnning(not even in the background) and I can update the server?
Posted
by
Post not yet marked as solved
1 Replies
563 Views
We are making application of ios. The application is for Disaster prevention in Japan. Because, Recentry in Japan has many Disaster in all season. We spplied to Local government in Japan and using general public and they are using well. One of the local government request to us, they want also supply to deaf person and help whe disaster occur. Local government already has disaster prevention broadcast but it is using loudspeaker. Then, when rains heavily, it can not hear to general public. And our application is from disaster prevention broadcast and forwarding to ios smartphone. It is helpfull to general public well. We are making new application it is not only prevention broadcast text but flashlight with iphone. But after making application, the flashlight is lighting only open our application. like beloe link. But, if Deaf person using it maybe he is not notice well. Our application is already has viblation function but Deaf person put his smartphone in his bag maybe I think he never noticed that Heavy rain and tsunami. Here is our application https://apps.apple.com/jp/app/cosmocast/id1247774270?mt=8 Here is application rule for flashlight. https://stackoverflow.com/questions/32136442/iphone-flashlight-not-working-while-app-is-in-background/32137434 I want help Deaf person and also senior citizens for Heavy rain and tsunami by our application. We'd like to make a flash light at the same time as the push notification arrived. Does anyone know a good way? Thank you and Best regards. Tomita.
Posted
by
Post not yet marked as solved
3 Replies
1.4k Views
Hello, from October we have started to do not receive responses of pushes sent to Apple servers. Last time it was day before yesterdeay from 14:00 to 14:30 , and today there are lots of pushes without responses from 14:25 and problem still continues. All time is Moscow time zone. Thanks, Zigurds
Posted
by
Post not yet marked as solved
11 Replies
14k Views
Hi Team, I was trying to add NSE to my Project to show Rich messaging. Creation of the NSE target to the project - Successful. Creation of additional provisioning profile in developer portal for NSE and mapped it in XCode - Successful The APS payload contains the content-type: 1 and attachment url to download the media content - Successful. When notification arrive the will present method gets called first - Successful. The auto execution of Notification Service 'didReceive(_ request: UNNotificationRequest,          withContentHandler contentHandler: @escaping            (UNNotificationContent) - Void)' - failure. 6. Tried running the target instead of main app - failure 7. Tried attaching a debugger to get break point - failure 8. Debug and Console logs - failure 9. Additionally tried the below option from every developer suggestion but no luck. o  https://stackoverflow.com/questions/50853503/images-in-ios-push-notification o  https://stackoverflow.com/questions/51722109/unnotificationserviceextensions-didrecieve-not-called o  https://stackoverflow.com/questions/39663903/ios10-unnotificationserviceextension-not-called o  https://stackoverflow.com/questions/46463680/notificationserviceextension-not-called o  https://stackoverflow.com/questions/45483018/unnotificationserviceextension-not-working-on-iphone-5-ios-10 Could you please assist on the same to get it working as the notification service methods cannot be called explicitly and it needs to be triggered by OS. A quick, faster response and resolution is much appreciated.
Posted
by
Post not yet marked as solved
6 Replies
5.1k Views
We have configured the push notification service (Server-provider) to communicate with APNS with hostname: api.sandbox.push.apple.com and Port: 443. APNS request is going successfully but from APNS to device (iPhone 6S ) not coming. We have whitelisted the above port and other ports also(2195, 2197). but. still not able to receive the notification. We have also cross verified with the old gateway.sandbox.push.apple.com:2195 and it's working fine but with new api.sandbox.push.apple.com:443, not working. Could someone from Apple Community help us to get resolved this issue? Thanks in advance!!
Posted
by
Post marked as solved
4 Replies
15k Views
I am trying to migrate to the new APNs Provider API. Here is how I've been registering for push notifications: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {     //-- Set Notification     if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])     {         // iOS 8 Notifications: Registering for notifications and types         [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];         [application registerForRemoteNotifications];     }     else     {         // iOS < 8 Notifications         _storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];         [[UIApplication sharedApplication] registerForRemoteNotificationTypes:          (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];     }     _storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:      (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];     if (launchOptions != nil)     {         NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];         if (dictionary != nil)         {             NSLog(@"Launched from push notification: %@", dictionary);             /*[self addMessageFromRemoteNotification:dictionary updateUI:NO];*/         }     }      return YES; } Within the last week, I have been using the following terminal command from Sending Push Notifications Using Command-Line Tools to successfully send a test push notification to a testing device. curl -v --header 'apns-topic: com.domain.appname' --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"Test"}}' --http2  https://api.sandbox.push.apple.com/3/device/258ecf658e25256c8f06ddb1138d5d536ba0e760a96ebd12d3b1dbe112857c58 Recently after creating provisioning profile and adding it to Xcode, the app no longer prints the device token in the debug window. After removing the provisioning profile from my Apple Developer account under profiles, I tried using a backed up version of the app which still prints a device token to the debugger window. When I copy the device token and enter it into the terminal command to send another test push notification, the terminal output is a 400 status code : {"reason":"BadDeviceToken"}* Closing connection 1 curl -v --header 'apns-topic: com.domain.appname' --header apns-push-type: alert --cert aps.cer --cert-type DER --key PushChatKey.pem --key-type PEM --data '{"aps":{"alert":"Hello From Faunna"}}' --http2  https://api.sandbox.push.apple.com/3/device/a146d82d4acea02c9ef6de5838174292d0e2cd18a40be17fb79334c5003a0058 * Could not resolve host: alert * Closing connection 0 curl: (6) Could not resolve host: alert *   Trying 17.188.138.73... * TCP_NODELAY set * Connected to api.sandbox.push.apple.com (17.188.138.73) port 443 (#1) * ALPN, offering h2 * ALPN, offering http/1.1 Enter PEM pass phrase: * successfully set certificate verify locations: *   CAfile: /etc/ssl/cert.pem   CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Request CERT (13): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Certificate (11): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS handshake, CERT verify (15): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server accepted to use h2 * Server certificate: *  subject: CN=api.development.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US *  start date: Feb  8 21:41:22 2021 GMT *  expire date: Mar 10 21:41:22 2022 GMT *  subjectAltName: host "api.sandbox.push.apple.com" matched cert's "api.sandbox.push.apple.com" *  issuer: CN=Apple Public Server RSA CA 12 - G1; O=Apple Inc.; ST=California; C=US *  SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7fbd4700aa00) > POST /3/device/a146d82d4acea02c9ef6de5838174292d0e2cd18a40be17fb79334c5003a0058 HTTP/2 > Host: api.sandbox.push.apple.com > User-Agent: curl/7.64.1 > Accept: */* > apns-topic: com.faunna.PushChat > Content-Length: 37 > Content-Type: application/x-www-form-urlencoded >  * Connection state changed (MAX_CONCURRENT_STREAMS == 1000)! * We are completely uploaded and fine < HTTP/2 400  < apns-id: 8DE6AA75-8E41-E95E-1FAF-51D93A8B3200 <  * Connection #1 to host api.sandbox.push.apple.com left intact {"reason":"BadDeviceToken"}* Closing connection 1 What is causing the bad device token output in this set up? And how should I be registering for remote notifications from this point forward?
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
since iOS 15, the notification icon doesn't work as it should. the icon has been defined: the situation happens in the same app, but in different ios versions when ios < 15 the black icon is shown in the notification (correctly) now, iOS 15 the white icon appears (I have no idea why) has anyone had a similar problem?
Posted
by
Post not yet marked as solved
1 Replies
946 Views
Hi there! For Safari Push Notifications, I'd like to know how I can listen a "notification received" event on my web site. The purpose is to execute some actions (code) when a push notification sent from my web server is received on my web page, such as counting them for statistics. Thanks
Posted
by
Post not yet marked as solved
2 Replies
1.5k Views
When I call the completion handler from the following User Notification Center delegate function and pass UNNotificationPresentationOptions.sound I still get the notification banner: override func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void ) { completionHandler(.sound) } All I want is a way to just make a notification sound without showing the notification while the app is in the foreground. Any ideas? This is how I am requesting authorization: [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: (UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler: ^ (BOOL granted, NSError * _Nullable error) { }]; This is the notification request: var notification = UNMutableNotificationContent() if (notification != nil) { notification.categoryIdentifier = "id" notification.sound = .default notification.title = "title" notification.body = "body" request = UNNotificationRequest( identifier: NSUUID().uuidString, content: notification, trigger: nil ) UNUserNotificationCenter.current().add(request) { (error) in }
Posted
by
Post not yet marked as solved
1 Replies
2.8k Views
My goal is to get the push notifications while I get the following error The following Swift pods cannot yet be integrated as static libraries when I run pod install . I have tried the foolowing methods. pod 'GoogleUtilities', :modular_headers => true pod 'FirebaseCoreInternal', :modular_headers => true I also tried with use_modular_headers! But it didn't work out. Could some one say a solution to this issue?
Posted
by
Post not yet marked as solved
6 Replies
2.8k Views
When an iPhone is paired with an Apple Watch and receives a critical alert, no sound is played. This makes it very easy to miss such notifications and defeats entirely the purpose of critical alerts. For context, we build an app that improves the care coordination of heart attacks. We send critical alerts to notify healthcare professionals of such emergencies. These events may occur at night, when the user does not wear the Watch, and will therefore be likely to miss the notification entirely, which can be catastrophic. I have searched online thoroughly for work-arounds but have not found anything. Others have asked this before elsewhere but have not found definitive answers: link. Is there anything we can do as developers to force critical alerts to be handled by the phone, or at least to force the phone to ring when receiving a critical alert? Edit: I am aware that in the Watch app, it is possible to prevent notifications from being mirrored by the Watch. However, this requires the end user to exit my app and navigate their settings. It is also impossible for my app to check if this was done correctly. As such, I am completely in the blind as to whether the user has set up their notifications correctly.
Posted
by
Post not yet marked as solved
3 Replies
1.6k Views
ITMS-90338: Non-public API usage - The app references non-public selectors in myApp _isKeyDown, _modifiedInput, _modifierFlags, handleNotification:, isPassthrough, onSuccess:, removeValuesForKeys:completion:. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed.
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
Hi, we've observed a weird behavior for a small amount of our user that we keep receiving the same token from APNs despite it's shown as Unregistered. When we try to send push to the token, we got an Unregistered error so we remove that token from our server. However, later we would receive an add token request from the client with the same token we just removed, and when we try to send to the token it returns Unregistered again so we remove the token again. This happened 3 times for a user in an hour. The identifierForVendor remains the same for all the requests. We also owns the client and I've checked client code that it's sending the token it received from didRegisterForRemoteNotificationsWithDeviceToken to the server.
Posted
by
Post not yet marked as solved
1 Replies
686 Views
I was trying to generate the apn auth key from apple dev account. I clicked on the download button and then the downloader downloaded the file as dowload.json format. And When opened the FCM. It requires p8 format. After that I generated another key and got it again as download(1).json. Now i cant generate more keys. How can i convert these two keys to p8 format?
Posted
by
Post not yet marked as solved
2 Replies
921 Views
Hi, We need to use silent notifications in our app, even when the user kills the app. We requested Apple to get a NSE Filtering Entitlement on December 02, 2022 with follow-up number: 814879299 But after nearly 2 months, we still haven't got a response. So we also sent a TSI (Technical Support Incident) on January 09, 2023 with follow-up number: 817249684. DTS (Developer Technical Support) said that we need to use this specific entitlement and he has no involvement in the entitlement request process. We need a quick response for the NSE Filtering Entitlement because our business depends on Apple's response. @Apple, is it possible to get an estimation date for the response? @iOS_developers, how long have you been waiting for that permission?
Posted
by
Post not yet marked as solved
8 Replies
2.8k Views
Dear fellow developers, I have an issue where my didReceiveRemoteNotification method in the AppDelegate is never called. Here's what I did: I am developing a SwiftUI application for iOS 15 and 16 and am currently running tests in an iPhone 14 Pro Simulator. My Xcode version is 14.2 and the simulator is running iOS 16.2. I am of course talking about the AppDelegate's application:didReceiveRemoteNotification:fetchCompletionHandler: method, not the deprecated one. I embedded the AppDelegate in the following way: @main struct MyApp: App {     @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate ... } The integration of my AppDelegate does work in general, meaning the didFinishLaunchingWithOptions is called. I added the background modes capability to my app, including both "Remote notifications" and "Background processing". With this configuration, I would expect the AppDelegate's method to be called. I tried sending different push notifications with different payloads and headers while having the app both in the background and foreground but without success. Just to rule out mistakes on my side that are obvious to someone else, this is how I embedded the method into my AppDelegate: class AppDelegate: UIResponder, UIApplicationDelegate { ... func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void ) { print("Method called!") completionHandler(.noData) } } And here are a few payloads and headers that I tested. I tried all of the following payloads with the following headers in any combination. apns-push-type=alert or apns-push-type=background apns-priority=5 or apns-priority=10 Example 1: Visible notification { "aps": { "alert": { "body": "Test" }, "badge": 1, "content-available": 1 }, "test": "data" } Example 2: Silent notification without badge update { "aps": { "content-available": 1 }, "test": "data" } Example 3: Silent notification with empty alert block and badge update, based on ideas from this thread { "aps": { "alert": {}, "badge": 0, "content-available": 1 }, "test": "data" } As I said, no matter whether my app is in the foreground or background, the method is never called. At the same time, the userNotificationCenter(_:willPresent:withCompletionHandler:) method of the UNUserNotificationCenterDelegate is called when the app is in the foreground. At this point, I am running out of ideas what I could possibly be doing wrong, so I hope someone else has an idea what else to try.
Posted
by
Post not yet marked as solved
1 Replies
684 Views
Hi, We have integrated LA in our app. We have noticed that sometimes LA won't update although APNs is giving 200. To debug this we have enabled LA along side push notifications. Noticed getting push notifications on time but LA is not updating. Not sure how to debug this? Is there anyone who has scaled LA successfully? Thanks
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
Hello Apple Community, I'm writing to seek your help in resolving an issue that I have been experiencing with push notifications on my newly created iOS app. Recently, I have created another new app from app store connect with push notification settings enabled using P12 certificate (Production & Sandbox SSL certificate) and it is in TestFlight not yet in app store. In that, I am not receiving push notifications from APNs. From the backend that has successfully sent responses to iOS using device token. But from the app side not receiving the push notification. Despite having enabled the notifications in the app settings. I have tested using the Push Hero Mac app by sending push to my app using P12 certificate, Bundle id, Device token and Message and app receiving the push successfully. But not receiving push while sending from backend server developed using c#. Same settings working fine in another app and that push notification was working fine using the p12 certificate. So I have replaced the existing app p12 certificate to the newly created app from the backend to send push notification and it is working fine. I have used below details: Certificate: Production & Sandbox SSL Certificate Port: 2195 gateway: gateway.push.apple.com:443 Mode: Production I have also tried restarting my device and force-quitting the app, but the problem persists. I am not sure what else to do at this point, and it is becoming increasingly frustrating to miss important updates and messages. I would appreciate any advice or solutions that you can offer to help me troubleshoot this issue. Has anyone else experienced this problem before, and if so, how did you resolve it? Thank you in advance for your help.
Posted
by
Post not yet marked as solved
1 Replies
715 Views
I am getting badge count when we have the apns notification on carplay but notification not displayed on the carplay screen. I have set mutable-content:1 also...Is there anything else to do get notification on carplay screen. In Iphone enabled carplay notification . Please help me
Posted
by