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

Widget Refresh through Silent Push Notification
I am trying to refresh my widget through Silent Push Notifications. I have the background value as well as content-value = 1. However 99% of the time if the app is in the background or has been fully terminated/exited, the silent push notification won't start the app. I also tried logging the method that runs when the notification is received and it seems like it only gets called once the app is re-launched manually. Do I need to do anything to get it to get my widget to refresh when some events happen on the backend? Android is really smooth when it comes to implementing similar logic.
0
0
569
Jul ’23
LocationPushServiceExtension is not calling
I have my own iOS app that works great. But I needed to connect Location Push Service Extension to this application. The steps I performed: I got the entitlement for location push type, created certificates, profiles for this service, then I implemented this service by connecting all profiles to it and adding to .entitlements com.apple.developer.location.push. In the AppDelegate of my application, I create a service that has a CLLocationManager in it, which monitors the departure of the application to the background and immediately calls the startMonitoringLocationPushes method. startMonitoringLocationPushes works fine and gives me APN token. But when I try to send a notification to the device, the service is not even called. The push structure looks like this: payload: {}, compiled: false, aps: {}, expiry: -1, priority: 10, topic: 'ru.profsoft.alertonDev.location-query', pushType: 'location' } [headers] { 'apns-topic': '<MainAppID>.location-query', 'apns-push-type': 'location' } I use a small service on Node JS to send push notification to APN and it successfully delivers them, and the Apple console also successfully delivers them But when device is successfully gets any location push, service is not calling. I started to use Debug -> Attach to process by PID or Name and got this error: Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=24 MB) But my LocationPushService contains only autogenerated code without any extra implementation. Also I checked Console and found these errors when I delivered push to the device: This is first error's description: Failed to get LSApplicationRecord for <RBSLaunchRequest| xpcservice<ru.profsoft.alertonDev.AlertonLocationPushServiceDev([osservice<com.apple.locationpushd>:201])>; "Launching extension ru.profsoft.alertonDev.AlertonLocationPushServiceDev(BB972E40-8E19-48D5-B05D-13A5D9D7005B) for host 201"> with error Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=1538, _LSFunction=runEvaluator} Can anybody help with this?
0
0
484
Aug ’23
MDM CSR vendor certificate renewal
Our Vendor MDM CSR certificate will expire in a month. We are trying to renew/update it, but we are unsuccessful. We keep getting the message "Certificate signature Verification failed because the signature is invalid." Has anyone dealt with the renewal, or can anyone advise? We do everything according to the Apple documentation, but unfortunately there is not as much about renewal the certificate as there is about initially creating it. Can anyone help? Thank you
1
0
614
Aug ’23
I have problem with fcm flutter notification on ios
I have enabled developer mode in flutter app development. I am using Firebase Cloud Messaging to send notifications. everything works fine There is a notification coming to the normal app. But after a while I can no longer send notifications to the app. {"multicast_id":5417898622260949101,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} The fcm device token doesn't seem to work. This caused me to request a new fcm device token. and after using it for a while, it came back like the first time Is this caused by the APN token being canceled? or caused by enabling developer mode to develop apps.
1
0
965
Aug ’23
iOS 17 Beta Spam Firebase Push Notifications
Hello everyone Our application started to spam the Firebase Push Notifications when the device had the iOS 17 Beta. This behavior does not happen in iOS 16, but it was reproduced in many iOS 17 Beta (Beta 3, 4 & 5). The issue goes like this: Our backend service uses an SDK Firebase to send one notification The user receives the notification Then after some minutes, the device starts to receive the same push notification with the old date-time, by intervals of 5 to 15 minutes We also got reports of other people with the same issue: https://stackoverflow.com/questions/76620368/spam-of-fcm-push-notifications-on-ios-17-beta https://github.com/kreait/firebase-php/issues/814 You can see the following screenshot of the output of this after 2 hours:
11
7
3k
Oct ’23
APN Key and Certificates
I recently began work on an app that uses push notifications and the app already has a version in the store. I no longer have access to the original development and distribution certificates. I know I need to generate new certs. However, will the new certificates work with the existing APN key, or will I have to generate a new APN key as well? Any links or info will help. Thanks.
1
0
402
Aug ’23
Clevertap
Clevertap issuing a notice that iOS push certificate has expired 1 day(s) ago. Upload a new one. But the original APNs are still going on and cannot download more than two. Also don't have any old certificates with me.
0
0
216
Aug ’23
Push Notification to Apple Wallet Passes failing with WinHttpException exception
I am trying to write some code to send a push notification to a pass on an Apple device using C# .NET and HttpClient over HTTP2 with client certificate authentication. When I run the code, I am seeing the below exception: InnerException = {"Error 12152 calling WinHttpWriteData, 'The server returned an invalid or unrecognized response'."} I am trying to find out why this code is failing? Is it possible to debug/troubleshoot this in some way? Running this code on Windows 10 OS Build version: 21H2 (19044). The application is built on .Net Framework 4.8 and tried using WinHttpHanlder versions 6 and also 7. Also, tried using other third party open source libraries like PushSharp and DotApns. PushSharp does not seem to support Http/2 and dotApns does not support certificate authentication for .net framework. We have no plans to migrate to .net Core. Below is my code: private static string pushToken = "dbc56849<hidden>"; private static string AppleApnServer = "https://api.sandbox.push.apple.com"; public static async Task<PushResult> SendPushNotificationToWalletPass(string notificationContent) { byte[] certificateData = LoadCertificate(); X509Certificate2 certificate = new X509Certificate2(certificateData, String.Empty, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); string url = $"{AppleApnServer}:443/3/device/{pushToken}"; StringBuilder payload = new StringBuilder(); payload.Append("{ \"aps\" : "); if (string.IsNullOrWhiteSpace(notificationContent)) { payload.Append("\"\" }"); } else { payload.Append(notificationContent); payload.Append(" }"); // close aps dictionary } var handler = new Http2Handler(); handler.ClientCertificates.Add(certificate); using (var httpClient = new HttpClient(handler)) { using (var request = new HttpRequestMessage(HttpMethod.Post, url)) { var messageGuid = Guid.NewGuid().ToString(); request.Content = new StringContent(payload.ToString()); request.Headers.Add("apns-id", messageGuid); request.Headers.Add("apns-push-type", "alert"); using (var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead)) { HttpStatusCode statusCode = response.StatusCode; string reasonPhrase = response.ReasonPhrase; bool success = response.IsSuccessStatusCode; Console.WriteLine($"APN {(success ? "Delivered Successfully!" : $"Failed to Send! :: StatusCode [{statusCode}] Reason [{reasonPhrase}]")} :: PushToken [{pushToken}]"); if (!success) { switch (statusCode) { case HttpStatusCode.Gone: // The device token is no longer active for the topic. return PushResult.DeviceNotRegistered; default: return PushResult.Failure; } } return PushResult.Success; } } } } public enum PushResult { Success = 0, Failure = 100, DeviceNotRegistered = 200 } // Apple APNS requires http2 but .Net Framework does not support http2 (only built in support in .net core) // found this workaround https://stackoverflow.com/questions/32685151/how-to-make-the-net-httpclient-use-http-2-0/43101990#43101990 private class Http2Handler : WinHttpHandler { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { request.Version = new Version("2.0"); return base.SendAsync(request, cancellationToken); } }
1
0
1.2k
Jan ’24
What could be causing the inconsistent behavior in notification processing when the Flutter app is in a killed state?
I'm developing a Flutter application that utilizes topic messaging to send notifications to iOS devices using Firebase Cloud Messaging (FCM). I've followed the FCM documentation to initialize the topic and set up an API for sending messages. The API is triggered every hour through a cron job on the server. When a topic message is received, the app displays a notification and performs some background processing. While the notification is successfully delivered when the app is in the background, I'm encountering inconsistent behavior when the app is in a killed state. What I've Tried: I've double-checked the implementation of the FCM topic initialization and the message sending API, and everything appears to be correct. I've also verified that the cron job on the server is running as intended and the API calls are being made regularly. The issue seems to be related to how the app behaves when it's not running in the background. Topic Initialisation: if (!Platform.isAndroid) { await FirebaseMessaging.instance.subscribeToTopic("ios-scheduling"); } API for delivering topic message: router.post('/', (req, res) => { const topic = "ios-scheduling"; const body = req.body; console.log("Request Body", req.body); const message = { notification: { title: "OsuniO", body: "You may have some pending tasks.", }, data: { "notificationType": body['notificationType'] }, apns: { payload: { aps: { contentAvailable: true, "interruption-level": "time-sensitive" } }, headers: { "apns-push-type": "background", "apns-priority": "5", "apns-topic": "io.flutter.plugins.firebase.messaging" } }, topic: topic }; console.log("message to be sent to the user: ", message); admin.messaging().send(message) .then((response) => { // Response is a message ID string. console.log('Successfully sent message:', response); res.status(200).json(message); }) .catch((error) => { console.log('Error sending message:', error); res.status(400).json({ message: error }).end(); }); }); module.exports = router; Expected Behavior: I expect that when a topic message is sent via FCM, regardless of whether the Flutter application is in the foreground, background, or killed state, the notification should be reliably displayed on the device. Additionally, the associated API should be triggered consistently to perform the required background processing.
0
0
586
Aug ’23
How to use com.apple.developer.usernotifications.filtering entitlement
I'm working on an iOS app and I'm trying to implement notification filtering using the com.apple.developer.usernotifications.filtering entitlement. I want my app to receive only specific remote notifications based on certain criteria. However, I'm having trouble getting this entitlement to work as expected. Can you provide a step-by-step guide on how to correctly use the com.apple.developer.usernotifications.filtering entitlement for notification filtering? What are the key points and considerations I should keep in mind? Where should I add the com.apple.developer.usernotifications.filtering entitlement? Should it be added to the main app target or an app extension? Could you provide an example of how the entitlement key-value pairs should be structured for filtering notifications? For instance, if I want to filter notifications with a specific title and subtitle, how should I format this in the entitlements file? How can I ensure that my entitlements file is correctly referenced in my app's target settings? Are there any specific configurations I need to be aware of? I appreciate your assistance in helping me understand how to effectively use the com.apple.developer.usernotifications.filtering entitlement for notification filtering in my iOS app. Thank you! Regenerate
1
0
690
Aug ’23
Background notifications and user interaction
The (archived) Local and Remote Notifications Programming Guide contains the following: To support a background update notification, make sure that the payload’s aps dictionary includes the content-available key with a value of 1. If there are user-visible updates that go along with the background update, you can set the alert, sound, or badge keys in the aps dictionary, as appropriate. The current documentation however reads: To send a background notification, create a remote notification with an aps dictionary that includes only the content-available key, as shown in the sample code below. You may include custom keys in the payload, but the aps dictionary must not contain any keys that would trigger user interactions. What caused this change and why is no longer supported to send additional keys (e.g. an alert dictionary) in the aps dictionary of a background notification?
0
0
489
Aug ’23
Apple Web Push API doesnt work with HTTP/2
Hello, i try to send a Web Push Notification to my Safari Webbrowser and use the "http2" Module from Node.js Every other Browser is able to receive my messages. I got the message "BadJwtToken" but when i use the same Authorization Key with a HTTP/1.1 Request, i got a Message on Safari. Is there a Problem with the API when i use the HTTP/2 Protocol? Has anybody the same Problem? I send exactly the same Headers and as i said other Push APIs from Mozilla,Chrome and Microsoft e.t.c. are working with my HTTP2 Client.
0
0
658
Aug ’23
Apple Wallet Pass Autoupdate
Hi All I have successfully created an Apple pass using PHP. The pass is added to the Apple wallet successfully. Now, I have to update the pass with a new value for one of the parameters in the pass. How do we update the value? Please refer to a sample PHP script for the same. I have checked the below sites, Here, they Mentioned only the input and output, as per the document I received the push token, What should I do after getting the push token? https://developer.apple.com/library/archive/documentation/PassKit/Reference/PassKit_WebService/WebService.html
1
0
663
Aug ’23