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

APNS Documentation

Posts under APNS tag

228 Posts
Sort by:
Post not yet marked as solved
0 Replies
138 Views
Apple recently introduced and presented Web Push, a new Web Kit tool permitting to send notifications to users on your websites and web apps. However, push notifications have been a thing on macOS since Mavericks. Therefore, what is the difference between these two things ?(https://developer.apple.com/notifications/safari-push-notifications/ ) and that new thing (https://developer.apple.com/videos/play/wwdc2022/10098/)
Posted
by
Post marked as solved
6 Replies
380 Views
Right after I receive a notification I want to execute a background task. I'm using firebase to receive notification. I can receive notification successfully with 'UNUserNotificationCenter' in the AppDelegate file. Now my goal is to send a "GET" - "PUT" request, right after I received a notification (only when the app is in background) I saw the documentation about Background Tasks: https://developer.apple.com/documentation/backgroundtasks But I can't found a way to execute a background task right after I receive a notification. Is anyone has any suggestion about that? Thank you
Posted
by
Post not yet marked as solved
1 Replies
159 Views
We use remote push notification with content available = 1, as per document it will wake up app, but it doesn't work properly, sometimes the app doesn't wake up. I have observed this behaviour mostly on iOS 15. We use this mechanism to send device location to our server. Why remote push notification doesn't wake up my app all the time ?
Posted
by
Post not yet marked as solved
0 Replies
136 Views
I'm trying to log when a user gets a silent notification using didReceiveRemoteNotification. Here is my code right now: func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void ) { print("Log here") application.applicationIconBadgeNumber = 0 completionHandler(.noData) } Here is the payload.apns file: "aps" : { "content-available" : 1, }, "acme1" : "bar", "acme2" : 42 If i open Console.app application I can see that the (simulator in this case) wakes up in the background when I drag and drop the payload but it never runs the didReceiveRemoteNotification function. The app is written in SwiftUI and has a seperate AppDelegate file. The app is also using Firebase Analytics and I have tried to set the FirebaseAppDelegateProxyEnabled to "NO" (false). Am I doing something wrong? Note: The function gets called when the app is in the foreground and I drag and drop a normal alert notification (not silent).
Posted
by
Post marked as solved
6 Replies
445 Views
Hi Since yesterday, there seems to be a problem with APNS Sandbox. In dev mode, the token is never registered. (didRegisterForRemoteNotificationsWithDeviceToken & didFailToRegisterForRemoteNotificationsWithError never called) The logs below seem to indicate a certificate expiry. Can you please confirm? Mant thanks erreur com.apple.apsd stream Trust evaluation failed: Error Domain=NSOSStatusErrorDomain Code=-67818 UserInfo={NSLocalizedDescription=<private>, NSUnderlyingError=0x10de796b0 {Error Domain=NSOSStatusErrorDomain Code=-67818 UserInfo={NSLocalizedDescription=<private>}}} apsd 2022-06-15 09:11:07.839890 +0200 erreur com.apple.apsd stream Failed to authenticate with policy <private> apsd 2022-06-15 09:11:07.840023 +0200 erreur com.apple.apsd stream Trust evaluation failed: Error Domain=NSOSStatusErrorDomain Code=-67818 UserInfo={NSLocalizedDescription=<private>, NSUnderlyingError=0x10dd14a10 {Error Domain=NSOSStatusErrorDomain Code=-67818 UserInfo={NSLocalizedDescription=<private>}}} apsd 2022-06-15 09:11:07.974462 +0200 erreur com.apple.apsd stream Failed to authenticate with policy <private> apsd 2022-06-15 09:11:07.974642 +0200
Posted
by
Post not yet marked as solved
0 Replies
109 Views
In the actual test, we found that if a large number of push messages are sent to the APNs server in a short time, some push messages will be received at a long interval. Is there a good way to make a large number of push messages arrive on time?
Posted
by
Post not yet marked as solved
1 Replies
164 Views
I have downloaded my app through TestFlight and have allowed push notifications for my app through TestFlight. (as shown in the picture) I have used this: https://github.com/Altaibaatar/APNS-with-auth-key-p8-using-PHP to trigger push notifications to my app. Additional changes I have made to the code: using (production) https://api.push.apple.com/3/device instead of (development) https://api.development.push.apple.com/3/device. When I triggered the script, it returns a "200" status code but I have not seen any notifications. Is there anything wrong with the script I am running or have I missed a step to implement push notifications? Thank you in advance!
Posted
by
Post not yet marked as solved
0 Replies
98 Views
I am beta testing an app on TestFlight and using Wonderpush for push notifications. I have 22 requested beta testers but I have 68 registered Wonderpush users. Somehow, there are 46 push notification registered users from China that were not invited through TestFlight. I talked with Wonderpush technical support who indicated there is no way to be registered as a push notification user without downloading the app. Anyone else have this problem? Is it possible to download an app on Testflight without being invited?
Posted
by
Post not yet marked as solved
0 Replies
112 Views
Can we implement background activities for longer period of time after a silent push notification is sent?
Posted
by
Post not yet marked as solved
9 Replies
731 Views
when i use NSURLSession have a https request,TLS always download server certificate,Instead of using cached certificates. Certificate related packages are as follows: 123 17.994520 106.53.111.71 192.168.199.159 TLSv1.3 1412 Server Hello, Change Cipher Spec, Application Data 124 17.994559 106.53.111.71 192.168.199.159 TCP 1412 443 → 65048 [ACK] Seq=1373 Ack=518 Win=30336 Len=1372 [TCP segment of a reassembled PDU]
Posted
by
Post not yet marked as solved
0 Replies
135 Views
Silent Push Notification is not received to the device. I am sending push notifications from the https://fcm.googleapis.com/fcm/send Request Payload: { "content_available": true, "apns_priority": 10, "data": { "title": "Title of the notification", "body": "This string has message", "deviceId": "f565fa30-b5b2-11ec-bb6c-79ad60e4f707" }, "registration_ids":[ "List of registered devices"] } Now when I send the notification. I am getting the notification randomly on the devices. I was sending notification to 5 devices. Now 3 devices were receiving the notification and 2 device didn't received. When the app is running in the foreground I am getting notification in all devices. When app is in background I am getting notifications. When app is killed by the user and even phone is locked I didn't receive any notification in couple of devices and received in other device. Now, when I open the app I immediately received the notification. I read an article from apple doc on silent push notification and there it is clearly mentioned that there is no guarantee of notification delivery to the device. I cannot use normal notifications because I am filtering data before the notification. If payload have device id which is equal to stored device id then I fired a local notification if not then notification is silent. Any solution for this issue?
Posted
by
Post not yet marked as solved
0 Replies
143 Views
I am using push kit and call kit to send VOIP notificatin from my server to my app. The notification's working fine, however it remains there for infinite time unless the user rejects or accepts the call. Is there any way to handle this? Like it automatically expires after 20 seconds.
Posted
by
Post not yet marked as solved
0 Replies
219 Views
Dear apple developer community... I am facing the problem on creating my own pushPacakge and .p12 webpush certificates file for safari push notifications. I follow all steps carefully on an official document here with my team. And also try to follow some tutorials on some blogs which corresponding to its. But it still doesn't work. Here's how my problem looks like I've got .p12 file then I've test to upload it into some push service like oneSignal, truePush and etc. It's able to upload the file but the push service still doesn't work. But if I used a provided .p12 from their service, the notification will working properly. I try to use my .p12 to generate a push package (pushPackage.zip). But the api log on my webServiceUrl keep showing me "{ logs: ['Signature verification of push package failed'] }". Even if I try all versions of AppleWWDRC (G1-G6) downloaded from here. And even I use an official php script (createPushPackage.php) file from apple apn document downloaded from here on the top right corner at companion file Here's what I've done so far to get my own .p12 file... Generate my own CSR file from mac keychain application Noted1: My appleId on my mac is an Admin role only on apple developer account (Not a Admin, Account Holder role) Noted2: I've try to enter an apple id with role Admin, Account Holder on a User Email Address field but it still doesn't work Login into an apple developer account console on apple developer site Go to identifier tab and create new webPushId identifier Enter description and webPushId(reverse domain name style which is web.com.herokuapp.kkwebpush) Come back to certificates tab and create new certificate (select webPushId radio button and click create) Choose webPushId that already created on step 4 from dropdown list then click on continue Upload CSR file that generated on step 1 into its Download .cer file Click on the downloaded .cer file from step 9 and generate .p12 file by keychain Here's how I create pushPackage.zip file Create folder to store all files needed ( reference from here ) which are AppleWWDRCA.cer Certificates.p12 (Generated from step 9 above) createPuchPackage.php (Official script from apple which already edit the path to Certificates.p12 and enter private key match with my Certificates.p12 password) intermediate.pem (Generated from export AppleWWDRCA.cer on keychain as intermediate.pem) pushPackage.raw (folder that contain both icon.iconset and website.json that already set matched webPushId and webServiceUrl inside website.json) So, the folder structure now look like this Then I start to run php createPushPackage.php inside this folder. After that I've got an unreadable format result on my terminal .But I still get a pushPackage.zip file stored at /tmp folder (At this point I think it might be fine with that unreadable format) . Head over to my tmp folder to move that pushPackage.zip file into my webServiceUrl endpoint directory for send a pushPackage when apple api model was called on window.safari.pushNotification.requestPermission ( Already set these 4 parameters below) url as my web service url to my endpoint websitePushID as my web site id registered on apple developer console userInfo as empty object {} callback as function as a callback function FINALLY MY FINAL QUESTIONS ARE... Are there any steps that I've missed? Why I keep getting { logs: ['Signature verification of push package failed'] } on my web service url log errors endpoint? Does my certificate is invalid? (If yes, what are all possible causes) Why I can't use my own .p12 file on other push services (oneSignal, truePush and etc.) that support custom upload .p12 file for safari push notification? * When I used a provided .p12 from their service, everything works fine (safari permission popup can appear). On the other hands, If I use my own .p12, I can upload its to their services but safari permission popup don't show up)? Any solution please? Thanks
Posted
by
Post not yet marked as solved
0 Replies
143 Views
Hi, I have a project to deploy captive portal for public internet access. With all the other devices is working fine (PC/Android/Ipad/Mac) except for IOS devices. IOS devices takes around 45 seconds to show the Captive Network Assistant (mini browser).  I am attempting to use the new captive network DHCP advertisement in option 114 as described here: https://developer.apple.com/news/?id=q78sq5rv to reduced this delay. But It appears that in the first attempt it uses the old method and makes an GET to http://captive.apple.com/hotspot-detect.html. However, if I rejoin the same network a second time (without forgetting the network inbetween) it uses the new DHCP option 114 and opens the captive portal as described in https://developer.apple.com/news/?id=q78sq5rv. Any idea o what is happening?
Posted
by
Post not yet marked as solved
0 Replies
165 Views
Hello everyone! I am trying to implement push notifications in my WatchOS app. I have created the delegate class that handles the registration for remote notifications and that allows me to obtain the device token. Then I take the token and send it to Firebase, like this: func didRegisterForRemoteNotifications(withDeviceToken deviceToken: Data) {     FirebaseApp.configure()     var ref: DatabaseReference!     ref = Database.database().reference().ref.child("/")     let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }     let token = tokenParts.joined()      if let userID = UserDefaults.standard.object(forKey: "id") as? String {         ref.child("users/\(userID)/token").setValue(token)     } } Then I am using a Python Script to communicate with APNS. I am using the http library to get access to HTTP2. This is what I have got: payload = { "aps" : { "alert" : { "title" : "Hello Push", "message": "This is a notification!" }, "category": "myCategory" } } dev_server = "https://api.sandbox.push.apple.com:443" device_token = "9fe2814b6586bbb683b1a3efabdbe1ddd7c6918f51a3b83e90fce038dc058550" headers = { 'method': 'POST', 'path': '/3/device/{}'.format(device_token), 'autorization': 'bearer' + 'provider_token', 'apns-push-type': 'myCategory', 'apns-expiration': '0', 'apns-priority': '10', } async def test(): async with httpx.AsyncClient(http2=True) as client: client = httpx.AsyncClient(http2=True) r = await client.post(dev_server, headers=headers, data=payload) print(r.text) asyncio.run(test()) I have also downloaded the .p8 auth key file. But I don't really understand from the Apple Documentation what I have to do with it. What is the provider token in the headers? Am I doing the right thing with the token I receive from didRegisterForRemoteNotifications?
Posted
by
Post not yet marked as solved
0 Replies
107 Views
We've observed a steady decline in the number of responses to APNS requests coming back with the "Unregistered" reason. Since about the beginning of 2022, we've noticed that "Unregistered" responses have dropped off altogether for the oldest device tokens recorded in our backend. Going by the APNS response status, it would appear we're still successfully sending messages to these very old device tokens, but this seems counter intuitive. We would expect the opposite, that over time those oldest device tokens would be the ones most likely to no longer be active (i.e. app uninstalled, devices no longer in use, etc.). Many of these devices tokens were recorded years ago, so we find it hard to believe that none of them would be inactive now. Does APNS stop providing meaningful response status for device tokens at some point? For example, if the device is no longer reachable (not working, never powered on or connected, etc.), would a request to send a message to that device still have a "Success" response? And if so, is there any way to determine if those device tokens are truly inactive or not?
Posted
by
Post not yet marked as solved
1 Replies
256 Views
All our applications listed below, once installed in padOS15 (iPad mini 6 15.4.1) are not receiving any remote push notifications. We built our apps in XCode13.2.1. I also tried to install the latest XCode13.3.1 in macOS Monterey, but I got the same problem. It has no problem when installed on different devices and versions. Our apps: CLOMO SecuredBrowser for iFilter CLOMO SecuredMailer CLOMO SecuredDocs CLOMO SecuredContacts This is how to replicate it: Start the app Press the home button and the app goes to the background I change the profile settings on our server-side Wait for the remote push notifications. (the remote push notifications are received on other devices but not on this device) Expected result: remote push notifications should be shown on the device. When I checked the console log, I found that com.apple.Preferences removed delivered notifications as shown below. SpringBoard [com.apple.Preferences] Removing delivered notifications
Posted
by