Hello I'm stuck and I need help.
I have an iOS application build with Angular2 + Cordova + cordova-firebase-plugin + xcode.
I have setup the app on developers.apple.com and firebase.console website.
Now when I try to send a Notification message, I don't receive it on Iphone at all.
If the application is runing in the foreground, I see in the debug console that the notification was received, but it is not displayed on the Iphone.
Message from console:
Received data message: {
"collapse_key" = "com.example.app"
from = 793840040300;
notification = {
body = "example test notification message";
e = 1;
}
}
What I don't see here: notification title. (The notifications are working in Android, but not in iOS).
There were no any prompts about enabling the notifications (permissions prompt).
I trieed to setup APNS-FCM connectivity via .p12 Certificates and via .p8 Certificates (via the key). Boths atemmpts did not give me positive result...
One more moment:
IF the application is running in the background - I don't see the message in the console until I will open the app. When I open the app, the message appears in the console, if it was sent while the app was in foreground..
I viewed many different guides, but I didn't get any result.
I read that emulators does not support the push notifications, so I connected a real device via USB. And it behaves the same - no push notification received - only the message in the console.
Please, help me.
Make sure you are sending both the title and body in the payload. I had the issue (in Android) that when not sending the message item, the notification would not show up in the notifications bar. The same applies for iOS, but in this case, the variables are title and body.
If the right variables are not found in the payload, both Android, iOS and Windows Phone will consider it a background notification that is silently delivered to the app (once it's opened). Notifications will not wake an unloaded app, the app is launched by the notification item once it's selected from the notifications bar in this case.
Try sending the default payload from the documentation to test it:
{
"aps": {
"alert": { // alternatively just a string: "Your Message",
"title": "A short string describing the purpose of the notification",
"body": "The text of the alert message",
// localization of message is possible
"launch-image": "The filename of an image file in the app bundle, with or without the filename extension. The image is used as the launch image when users tap the action button or move the action slider"
},
"badge": 5, // Number to show at App icon
"content-available": "0", // configure background updates, see below
"category": "identifier", // Provide this key with a string value that represents the notification’s type
"thread-id": "id", // Provide this key with a string value that represents the app-specific identifier for grouping notifications
"sound": "default" // play default sound, or custom sound, see [iOS Sound](#sound-1) section
},
"custom_key1": "value1",
"custom_key2": "value2"
}
If this doesn't work, please include the entire content of the payload you are sending to APNS, from the server side.
Edit: make sure you are sending your payload fields in UTF-8 encoding to all push services.
Related
I am sending notifications and data messages (non-notification) over APNS from FCM to my iOS App, and everything works fine in the foreground.
I would like to be able to trigger code when the App is in the background.
I already have "Enable Background Modes" "Remote Notifications" set in info.plist
However the following message does not trigger until I bring the App into the foreground
message = new Message()
{
Apns = new ApnsConfig()
{
Headers = new Dictionary<string, string>()
{
{ "content_available", "true" },
},
},
Data = new Dictionary<string, string>()
{
{"temperature", "warm"},
},
Topic = "thetopic",
};
1) can anyone tell me why this does not run immediately. I tried adding
{
"apns-priority", "10"
},
but this makes no difference, and indeed
Local and Remote Notification Programming Guide
states that
It is an error to use this priority for a push notification that
contains only the content-available key.
What am I missing here?
Is there any way at all in iOS that it is possible to cause an non-running App to run up in response to an APNS notification or message, without involving the user?
Is it possible under iOS to have an App permanently running (i.e. autostart) so that it can always respond to a notification or message?
You are sending "data message" - this will not work for apps that are not running. This is very poorly documented but you have to send "notification message" to awake your app. Just add
"notification":{
"title" : "title",
"body" : "body"
},
to your message to get it to work
You should consider creating a UNNotificationServiceExtension for that purpose.
See: https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
This is in fact a mini-app that is launched each time a notification is received, in which you can put your code.
I am using APNS push with content-type = 1. I receive the payload and fire using local notification.
this works fine in background and foreground mode
but when app is killed I get nothing.
what is the solution? I have seen people saying something about VOIP apps
but mine is not a VOIP app..
Some said to check Pushkin framework?
Any guidance?
Update
with this Json format I received notification when app was in killed state.. I checked on lower version 9.3 iOS.. have to check on iOS 11..
{
"aps": {
"content-available": 1,
"alert": "custom message ",
"badge": 1,
"sound": "solemn.wav"
},
"id": "55",
"data": "your data"
}
I don't think it can be done if your app is not a VOIP app. But, if you want to change the appearance of a push notification, you may want to look at the Notification Service Extension.
You have to include mutable-content flag as 1 in your payload inside aps. You cannot use content-type flag with this notification. Also, you have to show user something or the other after you have received the payload. Also, it is available in iOS 10 and above only.
Even with all these constraints, you can do some amazing things with this extension which were not possible earlier.
You can now show media attachment in the notification.
You can download small content or hit an API.
You can modify earlier sent push notification.
You can create a local notifcation center in your app.
We have a Django backend server using pyfcm to deliver Notifications throgh Firebase Cloud Messaging (FCM). I just updated to the today released Version 1.3.0. I want to send a notification using the loc-key and loc-args parameters so it can be displayed in the language the user is using on his phone. The notification reaches the device, it vibrates and makes the default sound for a new notification, but it will not displayed. It just happens nothing except for the sound and vibration.
This is the payload generated by the server which is sent to the fcm endpoint:
{
"notification": {
"loc-args": ["Demo (#demo)"],
"loc-key": "notification-follow",
"sound": "Default"
},
"priority": "high",
"to": "..."
}
On the client side, this is what is received by the phone:
[
AnyHashable("gcm.message_id"):0:1496257581534217 %f910cc44f910cc44,
AnyHashable("aps"):{
category = profile;
sound = Default;
},
AnyHashable("gcm.notification.alert"):{
"title-loc-key":" notification-follow",
"title-loc-args":[
"Demo (#demo)"
]
}
]
Is there anything I have to do before the message is displaying? Sending the message without the loc-key and loc-args but with message-body presents the notificaion on the device. Maybe the payload is wrong? How should it look like to do what I want?
The key, notification-follow in this case, is listed and translated in the Localizable.strings files in any available language.
Ok, problem solved. It was pyFCM. I thought it would be an error with this library, so the developer pseudo-fixed it. But it worked properly, and now it doesn't work anymore. The trick is to give body_loc_args an array, otherwise it will give you an InvalidParameters error.
I have an application in iOS that receives push notifications through GCM (Google Cloud Messaging) and APNS . These notifications contain some data that has to be processed before showing anything to the user.
After data processing, I generate a local notification with proper information to the user.
I see this behaviour:
With the app in foreground I only see the local notification.
With the app in background I see both notifications, remote and local.
With the app not even running, no notification is shown.
Can I show only my local notification after processing some data? (at least when the app is in background)
I have read about using content-available property as documented here, but the behaviour is almost the same.
Finally I get the solution (thanks to #DmytroShvecov for the pointer).
It is necessary to follow the official documentation here and follow these steps in the server:
Include inside aps keys alert, badge and sound but with blank value.
Include content-available key with 1 as value (if you want your notifications to be processed in background without interaction of the user.
Include any acme key to be treated as custom payload with your data.
This is an example of everything working together:
{
"aps": {
"alert": "",
"badge" : "",
"sound":"",
"content-available": 1
},
"acme": {
"what": "ever",
"you": "want"
}
}
I am currently working on an app and I have implement firebase Push Notification service into my app. I am recieving notification on my iphone but I am unable to set the custom alert sound that I want.
I added the sound as a .caf
I added the sound to the Copy Bundle Resources
using print (userInfo) I have collected this data that is incomming from Firebase
aps: {
alert = {
body = MSG;
title = Title;
};
sound = default;}, {...}, sound: alarm.caf
I understand where the problem is, I just dont understand how to fix it so that the app plays my custom notification sound.
Problem with Firebase is that you can not send sound parameter like custom parameter with Firebase Console, if you try this as you do, you will get this parameter in app outside of aps Dictionary and the system will not recognize it as a sound to be played although the sound file is into the project.
The only solution for this problem is you have some API/server through which you'll be sent a Firebase notification. When server send you a notification with sound param it will be within aps Dictionary and application will play this sound when the notification arrives.
After much research I have not found any solution.
Under Firebase Messaging Docs, and
Table 2a. iOS — keys for notification messages
it is indicated that Firebase does allow for the Sound key to be included in the payload but as seen in the code printed by didRecieveRemoteNotification,
aps: {
alert = {
body = MSG;
title = Title;
};
sound = default;}, {...}, sound: alarm.caf
Firebase doesn't include the Sound key inside the aps hence not calling the sound key by the app.
The workaround that I used for my app is Easy APNs Provider which is a handy and easy app to use for development purposes, a major issue is that it doesn't have the ability to register and remove notifications automatically.
lastly: for Push Notifications to my published apps, I have opted for a dedicated server which I run off of my website
It's been over 5 years, but if someone still looking for an answer, here is what I did.
Make sure you have configured Firebase Messaging & receiving Notifications.
Add .caf ( sound file ) to the app. It must be visible on
'Target' - > 'Build Phases' & then under 'Copy Bundle Resources'
Delete the app from the device ( This is important )
I use Postman as my server, so message format would be,
{
"notification": {
"title": "Hello",
"sound":"small_message.caf",
"body": "You have a new Job"
},
"to": "your device token"
}