Push notification not receiving message in ios


#1

Hi, friends I am unable to receive message using push notification on ios.I am able to send and receive messages in Android and able to send message from ios but not able to receive any notification please help…


#2

Hey!

What are you using in terms of the push server? Google Firebase Cloud Messaging, OneSignal or do you handle everything on your own?

If you use Google Firebase Cloud Messaging I can help you out. Basically what you need to do is to go into the Firebase Console, under Cloud Messaging choose your app for iOS, you should have already added the Apple APN certificates, or better yet, the APN key so Firebase handles that on its own.
You then need to download the GoogleService-Info.plist file and via XCode add it to your app projects Resources folder.

I’d imagine with OneSignal it is likely similar. When you use your own Push Server then you need to use the APN certificate to do some extra things. Maybe check out this Git Repo for a NodeJS based solution, should give you an idea how to do it, even if you use something else. https://github.com/node-apn/node-apn


#3

hi, Thank you so much for your reply.now I added the Apn key in the fcm console under cloud messaging but still not able to get any message on ios.After adding APN key generated new GoogleService-Info.plist file also and added in root directory still not working.what can be the problem? there is no error also.when i send message from fcm console it shows completed status too.


#4

did you finally solve it?


#5

@lqrz
Yes.Actually the problem was with the payload.


#6

Hi mathewk, I get the same problem as you.

  • I think I config everything on Apple, create AppId, add Apn key too. But when I try pushing a notification from firebase console, my app did not receive notification even it registered the FCM token. (Android is working fine)

Can you show me your solution?

Thank you


#7

Hi, I have the same problem.

I configured everything was possible on Apple, created APN key (.p8) and before this, tryed with certificates (.p12). Added GoogleService-Info.plist with IS_GCM_ENABLED true to my project correctly (in fact, while compiling, it’s automatically added to iOS project folder and read by device).

It seems that my server sends successfully notifications to Firebase:

“Successfully sent with response: {“multicast_id”:8404586266050937268,“success”:1,“failure”:0,“canonical_ids”:0,“results”:[{“message_id”:“0:1541585250836741%5572c81aa485705f”}]}”

But I have no signal from my iOS device (iPhone 5S, iOS v. 11.2.1). When installing application, the device prompt me to accept permissions on notification and settings are added into notification system settings (“badge, sounds, banner” enabled).

If the problem is into payload, please share your solution. I’m facing this issue for days with no solution.

Now I’m trying this payload, but not worked for me:

// PAYLOAD
{
“to”: token_of_device_associated,
“collapse_key”: name_of_app,

            // iOS
            "aps": {
                "alert": "Test background push",
                "content-available": 1
            },
            // Android
            "data": {  // you can send only notification or only data(or include both)
                "title":    `${user.name} ${user.surname}`,
                "message":   mess.content,
                "soundname": "default"
            }

}

These are settings onto device:

// OPTIONS
const options: PushOptions = {
android: {
sound: ‘true’,
vibrate: ‘true’
},
ios: {
fcmSandbox: ‘true’,
alert: ‘true’,
badge: ‘true’,
sound: ‘true’
},
windows: {}
/,browser: {
pushServiceURL: ‘http://push.api.phonegap.com/v1/push
}
/
};

I tried also without fcmSandbox, but not worked too.


#8

Try building with the legacy build system in Xcode. The Firebase plugin seems to have issues with the new build system.

File > Project Settings -> Legacy Build System.

Also, watch your device log when running via Xcode. Firebase will (usually) log warnings about config issues.


#9

I already switched to Legacy Build System in Xcode and the plugin-phonegap-push seems to register correctly to service but never executo on(‘notification’) function.


#10

@danielnvd

Hi Daniel, I solved my problem by just changing the payload. will show you sample payload which worked for me in ios.

message = {
to: fcmId,
priority: “high”,
category: category,
“sound”: “default”,
notification: {
title: “your title”,
body: message
},
data: {
infos: “walking”, // data which you are sending with the notificaion
randid: randomid . // to avoid double event trigger
},
};

Did you add GoogleService-Info.plist to the root folder?