Firebase Push Notification and IOS APNs Notification when app killed The 2019 Stack Overflow Developer Survey Results Are InWhat is difference between remote notification and silent notification in iOS?GCM push notification when iOS app is in the backgroundFirebase onMessageReceived not called when app in backgroundFirebase silent apns notificationFCM iOS send push notification to a topic to killed appFirebase FCM silent push notifications for iOSFirebase Push Notification not sending to APNiOS Push Notifications not received when app is terminated using Firebase Data MessagesIs firebase not always sending notifications through APNs?Firebase Cloud Messaging returning InvalidApnsCredential despite valid P8 APNs Auth Key existingHow to send bulk push notifications via APNS or Pushkit in IOS?
Return to UK after having been refused entry years ago
Is there a symbol for a right arrow with a square in the middle?
What tool would a Roman-age civilization have for the breaking of silver and other metals into dust?
Is flight data recorder erased after every flight?
Delete all lines which don't have n characters before delimiter
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Is "plugging out" electronic devices an American expression?
Resizing object distorts it (Illustrator CC 2018)
Why is the Constellation's nose gear so long?
Why isn't airport relocation done gradually?
If a Druid sees an animal’s corpse, can they Wild Shape into that animal?
Worn-tile Scrabble
Multiply Two Integer Polynomials
One word riddle: Vowel in the middle
Who coined the term "madman theory"?
Does coating your armor in silver add any effects?
What is the accessibility of a package's `Private` context variables?
How to save as into a customized destination on macOS?
Geography at the pixel level
Interpreting the 2019 New York Reproductive Health Act?
Pokemon Turn Based battle (Python)
Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?
A poker game description that does not feel gimmicky
How to deal with fear of taking dependencies
Firebase Push Notification and IOS APNs Notification when app killed
The 2019 Stack Overflow Developer Survey Results Are InWhat is difference between remote notification and silent notification in iOS?GCM push notification when iOS app is in the backgroundFirebase onMessageReceived not called when app in backgroundFirebase silent apns notificationFCM iOS send push notification to a topic to killed appFirebase FCM silent push notifications for iOSFirebase Push Notification not sending to APNiOS Push Notifications not received when app is terminated using Firebase Data MessagesIs firebase not always sending notifications through APNs?Firebase Cloud Messaging returning InvalidApnsCredential despite valid P8 APNs Auth Key existingHow to send bulk push notifications via APNS or Pushkit in IOS?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am using Google Firebase to send push notifications. For Android client, I only send data (not notification) and if notification required, I send it as local notification and it works fine. Data arrive whether the app is running or killed or in the background. In IOS, I configured APNs with Firebase but I have some trouble about background data and notification. The code below sends background data to IOS client by using APNs. "content_available" flag direct notification to APNs but as Firebase documentation mentioned, APNs are not guaranteed to be delivered. The link below explains it.
https://firebase.google.com/docs/cloud-messaging/http-server-ref
"On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported."
If I add the codes at the comment lines, APNs sent always notification whether the app is in foreground, background or killed. Of course, I don't want push notification if the app is in the foreground. Furthermore, if the user doesn't click the notification (click the app icon), the code is not triggered. Is there any way to use APNs as Firebase on Android? In Android background data notification always sent to the client successfully whether the app is in the foreground, background or killed.
private static String apiKey = "AIzaSy............";
public static void sendNotification(JSONObject jsonData, String token)
try
JSONObject jsonGCM = new JSONObject();
jsonGCM.put("to", token);
jsonGCM.put("data", jsonData);
jsonGCM.put("content_available", true);
//jsonGCM.put("priority", "high");
/*JSONObject jsonNotification = new JSONObject();
jsonNotification.put("title", "Some Title");
jsonNotification.put("body", "Some body.");
jsonGCM.put("notification", jsonNotification);*/
URL url = new URL(
//"https://gcm-http.googleapis.com/gcm/send");
"https://fcm.googleapis.com/fcm/send");
HttpsURLConnection conn = (HttpsURLConnection) url
.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-Type",
"application/json; charset=UTF-8");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "key="
+ apiKey);
OutputStream os = conn.getOutputStream();
os.write(jsonGCM.toString().getBytes("UTF-8"));
os.flush();
InputStream in = new BufferedInputStream(
conn.getInputStream());
System.out.println("Response code -->"
+ conn.getResponseCode());
os.close();
catch (Exception e)
// TODO: handle exception
ios firebase apple-push-notifications firebase-cloud-messaging
add a comment |
I am using Google Firebase to send push notifications. For Android client, I only send data (not notification) and if notification required, I send it as local notification and it works fine. Data arrive whether the app is running or killed or in the background. In IOS, I configured APNs with Firebase but I have some trouble about background data and notification. The code below sends background data to IOS client by using APNs. "content_available" flag direct notification to APNs but as Firebase documentation mentioned, APNs are not guaranteed to be delivered. The link below explains it.
https://firebase.google.com/docs/cloud-messaging/http-server-ref
"On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported."
If I add the codes at the comment lines, APNs sent always notification whether the app is in foreground, background or killed. Of course, I don't want push notification if the app is in the foreground. Furthermore, if the user doesn't click the notification (click the app icon), the code is not triggered. Is there any way to use APNs as Firebase on Android? In Android background data notification always sent to the client successfully whether the app is in the foreground, background or killed.
private static String apiKey = "AIzaSy............";
public static void sendNotification(JSONObject jsonData, String token)
try
JSONObject jsonGCM = new JSONObject();
jsonGCM.put("to", token);
jsonGCM.put("data", jsonData);
jsonGCM.put("content_available", true);
//jsonGCM.put("priority", "high");
/*JSONObject jsonNotification = new JSONObject();
jsonNotification.put("title", "Some Title");
jsonNotification.put("body", "Some body.");
jsonGCM.put("notification", jsonNotification);*/
URL url = new URL(
//"https://gcm-http.googleapis.com/gcm/send");
"https://fcm.googleapis.com/fcm/send");
HttpsURLConnection conn = (HttpsURLConnection) url
.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-Type",
"application/json; charset=UTF-8");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "key="
+ apiKey);
OutputStream os = conn.getOutputStream();
os.write(jsonGCM.toString().getBytes("UTF-8"));
os.flush();
InputStream in = new BufferedInputStream(
conn.getInputStream());
System.out.println("Response code -->"
+ conn.getResponseCode());
os.close();
catch (Exception e)
// TODO: handle exception
ios firebase apple-push-notifications firebase-cloud-messaging
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08
add a comment |
I am using Google Firebase to send push notifications. For Android client, I only send data (not notification) and if notification required, I send it as local notification and it works fine. Data arrive whether the app is running or killed or in the background. In IOS, I configured APNs with Firebase but I have some trouble about background data and notification. The code below sends background data to IOS client by using APNs. "content_available" flag direct notification to APNs but as Firebase documentation mentioned, APNs are not guaranteed to be delivered. The link below explains it.
https://firebase.google.com/docs/cloud-messaging/http-server-ref
"On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported."
If I add the codes at the comment lines, APNs sent always notification whether the app is in foreground, background or killed. Of course, I don't want push notification if the app is in the foreground. Furthermore, if the user doesn't click the notification (click the app icon), the code is not triggered. Is there any way to use APNs as Firebase on Android? In Android background data notification always sent to the client successfully whether the app is in the foreground, background or killed.
private static String apiKey = "AIzaSy............";
public static void sendNotification(JSONObject jsonData, String token)
try
JSONObject jsonGCM = new JSONObject();
jsonGCM.put("to", token);
jsonGCM.put("data", jsonData);
jsonGCM.put("content_available", true);
//jsonGCM.put("priority", "high");
/*JSONObject jsonNotification = new JSONObject();
jsonNotification.put("title", "Some Title");
jsonNotification.put("body", "Some body.");
jsonGCM.put("notification", jsonNotification);*/
URL url = new URL(
//"https://gcm-http.googleapis.com/gcm/send");
"https://fcm.googleapis.com/fcm/send");
HttpsURLConnection conn = (HttpsURLConnection) url
.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-Type",
"application/json; charset=UTF-8");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "key="
+ apiKey);
OutputStream os = conn.getOutputStream();
os.write(jsonGCM.toString().getBytes("UTF-8"));
os.flush();
InputStream in = new BufferedInputStream(
conn.getInputStream());
System.out.println("Response code -->"
+ conn.getResponseCode());
os.close();
catch (Exception e)
// TODO: handle exception
ios firebase apple-push-notifications firebase-cloud-messaging
I am using Google Firebase to send push notifications. For Android client, I only send data (not notification) and if notification required, I send it as local notification and it works fine. Data arrive whether the app is running or killed or in the background. In IOS, I configured APNs with Firebase but I have some trouble about background data and notification. The code below sends background data to IOS client by using APNs. "content_available" flag direct notification to APNs but as Firebase documentation mentioned, APNs are not guaranteed to be delivered. The link below explains it.
https://firebase.google.com/docs/cloud-messaging/http-server-ref
"On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc. On Android, data messages wake the app by default. On Chrome, currently not supported."
If I add the codes at the comment lines, APNs sent always notification whether the app is in foreground, background or killed. Of course, I don't want push notification if the app is in the foreground. Furthermore, if the user doesn't click the notification (click the app icon), the code is not triggered. Is there any way to use APNs as Firebase on Android? In Android background data notification always sent to the client successfully whether the app is in the foreground, background or killed.
private static String apiKey = "AIzaSy............";
public static void sendNotification(JSONObject jsonData, String token)
try
JSONObject jsonGCM = new JSONObject();
jsonGCM.put("to", token);
jsonGCM.put("data", jsonData);
jsonGCM.put("content_available", true);
//jsonGCM.put("priority", "high");
/*JSONObject jsonNotification = new JSONObject();
jsonNotification.put("title", "Some Title");
jsonNotification.put("body", "Some body.");
jsonGCM.put("notification", jsonNotification);*/
URL url = new URL(
//"https://gcm-http.googleapis.com/gcm/send");
"https://fcm.googleapis.com/fcm/send");
HttpsURLConnection conn = (HttpsURLConnection) url
.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-Type",
"application/json; charset=UTF-8");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "key="
+ apiKey);
OutputStream os = conn.getOutputStream();
os.write(jsonGCM.toString().getBytes("UTF-8"));
os.flush();
InputStream in = new BufferedInputStream(
conn.getInputStream());
System.out.println("Response code -->"
+ conn.getResponseCode());
os.close();
catch (Exception e)
// TODO: handle exception
ios firebase apple-push-notifications firebase-cloud-messaging
ios firebase apple-push-notifications firebase-cloud-messaging
edited Mar 8 at 10:50
KENdi
5,8792922
5,8792922
asked Mar 8 at 9:53
Efe AYDINEfe AYDIN
15112
15112
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08
add a comment |
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060667%2ffirebase-push-notification-and-ios-apns-notification-when-app-killed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060667%2ffirebase-push-notification-and-ios-apns-notification-when-app-killed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Yes, the silent notifications are not reliable. I didn't understand why can't you use normal Push Notifications for iOS?
– Sachin Vas
Mar 8 at 10:02
What do you mean with normal Push Notification? Is it the notification at the top of the screen? I want Whatsapp style notification. I want the same behaviour in foreground, background and killed.
– Efe AYDIN
Mar 8 at 10:07
stackoverflow.com/questions/42275060/…
– Sachin Vas
Mar 8 at 10:08