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.
Notifications
RSS for tagLearn about the technical aspects of notification delivery on device, including notification types, priorities, and notification center management.
Post
Replies
Boosts
Views
Activity
As Swift give as async await functions, I tried to use them for push notifications. In my case if I use
extension TMNotificationCenter: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.sound, .banner, .list, .badge])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
}
There are no error, erevything works fine, but when I change to this:
extension TMNotificationCenter: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
print(#function)
return [.sound, .banner, .list, .badge]
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
print(#function)
}
}
I got crash:
What I am doing wrong?
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:
You have already reached the maximum allowed number of Keys for this service.
How do I fix this?
If I schedule for example three local notifications and attach three different copies of the same image (copies are done before scheduling). Then if user in the notification center selects "Clear" on the first notification, then the next two notifications will be missing the attached image (although it was handed different copies of the same image).
I already know that when scheduling a local notification with an image, iOS will either copy or move the supplied image (depending on file location) to some temp storage it uses for local notifications. So I make sure to first take individual copies of the image and then hand them to the local notification.
I did find an ugly workaround to this problem that works. That for each copy of the image I slightly modify the image size and jpg compression of that identical image, then it doesn't happen.
It's like iOS image duplicate detection logic is activated for local notifications, and I'm fighting some "hash", business-logic or machine learning evaluation if the images are duplicates and should be removed for all attachments when clearing notification (or the folder of the attachments). Which seems wrong.
Bonus info: I even tried that if I only changed jpeg compression slightly on a small picture (200x200) then it could still happen, but if I then at the same time changed the image size by 1 pixel it would be fine. I also tired changing the same small image by 1pixel without compression then the problem happened.. So it feels like it's not a hash of the image (like MD5) but rather some logic or machine learning evaluation.
I have on my to-do to try a one color image to see if that triggers the problem no matter size and compression, just for my curiosity.
Experienced on iOS 15.6+ and 16+
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.
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.
I had called "registerforremotenotifications", but "didRegisterForRemoteNotificationsWithDeviceToken" and "didFailToRegisterForRemoteNotificationsWithError" not been callback, so that I should not get DeviceToken. Credentials, Compile options and so on, I had check all of them.
what's the reason? Networking or APNs overload?and other?
Please help to check.
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);
}
}
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.
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
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?
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.
I need to create identifier for my apple push notification system but i am not able to find add icon near identifier please help
I'm implementing Push To Talk functionality on my app.
Now I have some trouble after app process is terminated by user.
In my implementation, I download voice file in func channelManager(_ channelManager: PTChannelManager, didActivate audioSession: AVAudioSession) method. It works fine when app is foreground, and also ok when app is background until app process terminated.
After app process terminated, system displays PTT connection status by blue icon in status bar. Then I got some PTT message from another person, func incomingPushResult(channelManager: PTChannelManager, channelUUID: UUID, pushPayload: [String : Any]) and func channelManager(_ channelManager: PTChannelManager, didActivate audioSession: AVAudioSession) are called, but download process is not finished and I cannot get voice file.
What is the expected way to download voice file in such case?
I want to schedule a local notification every day at a particular time. When I receive the local notification I need to start location service irrespective of the app state. i.e. even when the app is killed or in the background I want this to be done.
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
index.php
after running this file i am getting this error
bool(false) Curl failed with error: SSL read: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca, errno 0Response from apple -> Curl Error
index.php
After running this code I am getting error
bool(false) Curl failed with error: SSL read: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca, errno 0Response from apple -> Curl Error
I've set up a Notification Content Extension for my app, but it's not getting called(tried both local and remote push). I've read the Apple dev guide, and I've set up everything as it says. https://developer.apple.com/documentation/usernotificationsui/customizing_the_appearance_of_notifications
I've looked over the common issues (setting proper deployment targets and setting category identifiers from the backend and in the .plist)
After receiving the notification, I'm not able to get the expanded view and neither is the didReceive(_ notification: UNNotification) of my extension view controller getting invoked. Is there something I'm missing while doing the extension setup, I m not able to figure out the problem?
Also, I m not able to understand this note from apple
"Notification content app extensions are supported only in iOS apps"
when all the Notification content Extension APIs are provided for MacOS also?