Google cloud messaging not receiving notifications on iOS - ios

I am using GCM in iOS for receiving notifications, the client app connects to GCM, receives registration token and successfully subscribe to topic but still fails to receive any notification.
The payload I am sending is
{"to": "/topics/test", "notification": {"body" : "Test"}}
to
http://android.googleapis.com/gcm/send
the response I receive from the server is
{ "message_id": 5517207416953280202 }
but still no notifications, can someone please point me to the right direction?

Related

Not Receiving Push Notifications on iOS using CapacitorJS and Ionic

Following the guide on Capacitor's site for push notifications, I am unable to receive any push notification inside my iOS device.
https://capacitorjs.com/docs/apis/push-notifications
I've triple checked that the Apple Push key and sandbox/production certificates are uploaded
I have successfully registered to the APNs and get a token value, but when I use Firebase to send a message to the token, I receive no notification.
I've also tried to send a message directly using this solution https://www.c-sharpcorner.com/UploadFile/pandeypradip/apple-push-notification-using-Asp-Net/ and I can send the message successfully, but I receive no response at all.
My app capabilities:

iOS Firebase push notifications alert

When my app is running in foreground and I send a notification from my web server (PHP), the iPhone does not alerts that the message arrived. I know that the message arrives because I save it on internal database and I can see it in a viewcontroller.
That's my JSON packet:
{
"data": {
"mensagem":"msg",
"dataEnvio":"2017-01-2016:06:58"
},
"content_available":true,
"time_to_live":3600,
"priority":"high",
"notification":{
"title":"new",
"sound":"default",
"body":"msg"
},
"registration_ids":["..."]
}
The same problem does not happens on Android.
Someone know what this is happening?
When the app is in the foreground the notification portion of the push notification is neglected in both android and ios. I am sure that you are creating the push notification yourself in android on the handling function OnMessageReceived so that it appear when you are foreground.

No notification is shown on iOS (sent with Firebase) while the app is in the background

I have a (Nativescript) iOS client app that should be able to receive a push notification sent by Firebase. It actually does receive data when the app is in the frontend, but as the documentation states, iOS should detect an incoming notification (when the app is in the background) and display the notification.
This last part just doesn't seem to work. I tried a lot, but can't figure out what's going on here.
I'm sending the notification by using the Firebase console. There's just nothing happening on my iPhone here, no sound, no badge, nothing!
While Firebase claims everything just works fine...?!
Can anybody help me?
Okay, so I guess I wasn't very specific, so let me add some code below.
I am posting this code to Firebase (https://fcm.googleapis.com/fcm/send) to trigger the push notification:
Content-Type:application/json
Authorization:key=[MY_KEY_HERE]
{
"to" : "[FIREBASE_DEVICE_ID_HERE]",
"priority": "high",
"notification" : {
"body" : "Howto write a great body?",
"title" : "Some title...",
"sound" : "default"
}
}
As you can see, this is a notification message, not a data message, so it should trigger a popup, badge, sound, or whatever on iOS...right?
As I mentioned before, I am able to receive this json data, but only if my app is in the foreground... So the Firebase-device-id is absolutely right and also is the authorization key.
What else should I try?
FCM Data-Messages are not displayed while the app is in background :
On iOS, FCM stores the message and delivers it only when the app is in the foreground and has established a FCM connection.
Source here : FCM Documentation
Be sure to sens Notification and not a Data message
Maybe you are disconnecting from Firebase with such command
[[FIRMessaging messaging] disconnect];
Could you tell if you can send message via APNS from your computer (without Firebase)? Example file to send such message can be found somewhere in this tutorial https://www.raywenderlich.com/123862/push-notifications-tutorial .

How can I know that push notification delivered or not in iOS?

I'm using FCM (Firebase cloud messaging) to receive push notifications.
Everything is working for me.
But from my server side they will send notifications continuously to my app with time as body up to some time.
Now I have to push notification only once where the time I am getting from server reaches current time.
Before current time and after current time notifications should not be shown.
I don't have any idea how to do this.
Can any one explain if is there any way to get this.
You can customize you notification arrival schedule by implementing cron jobs on your server.
And if you are using any API to push notification to any device just get the success message or delivered message after calling.
I have created an endpoint on a PHP server that takes an autoId referring to a notifications/$autoId in my realtime database. The sender of the notification writes the notification data to the database and if successful sends a POST request to http://myserver.com/notifications/$autoId/send.
This seems authentication-less however no one will know the notification id being sent apart from the user who created it and the user who receives it. On the server side, when the message successfully sends using FCM, we can set {"sent": true} to prevent it from being sent more than once. When the notification is received by the user, we set {"received": true}.
{
"notifications": {
"$autoId": {
"sent": false,
"received": "false",
"userInfo": {
"notificationId": "$autoId",
"toId": "$toUid",
"fromId": "$fromUid"
}
}
}
}

What is server address to send request for push notification on ios apn

I am using phonegap-plugin-push for sending push notification using GCM I send requests to https://android.googleapis.com/gcm/send but for ios using apn I couldn't find server address to send notification data.
What is address for using apn?

Resources