Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Notification is not shown on ios device #1121

Closed
RezaRahmati opened this issue Jul 27, 2016 · 21 comments
Closed

Notification is not shown on ios device #1121

RezaRahmati opened this issue Jul 27, 2016 · 21 comments

Comments

@RezaRahmati
Copy link

RezaRahmati commented Jul 27, 2016

Hi guys

I am using GCN's APN, app is building for ios, it successfully gets token, and I can successfully can send data to gcm, but no notifications appear on device

My code is

var push = PushNotification.init({
                android: {
                    senderID: "1234"
                },
                browser: {
                    pushServiceURL: 'http://push.api.phonegap.com/v1/push'
                },
                ios: {
                    alert: "true",
                    badge: "true",
                    sound: "true",
                    gcmSandbox: "true",
                    senderID: "1234" //same as android
                },
                windows: {}
            });

            push.on('registration', function (data) {
                alert(data.registrationId);
            });

            push.on('notification', function (data) {
                alert(JSON.stringify(data));
            });

            push.on('error', function (e) {
                alert(e.message);
            });

and message body is

{

    "to":"l20a0f4EPMw:APA91bEQnIO9AIrLTW6hr8es4EFnMy6iWQQMQdrJAgG0g6Br4etu357sRn8tGJAulSFHuDXY81HDmMl4-nc6Ou0zJcOZmzSEGc3YeD2zU67bpqOYmBsk80AnJTzJXstHS_FlE-0fFR1p",
    "data": {
        "title": "Large Icon",
        "message": "Loaded from assets folder",
        "image": "www/images/daivatech.png",
        "soundname": "default",
        "style": "picture",
        "summaryText": "There are %n% notifications",
        "picture": "http://jarchee.ca/api/Post/GetThumbnailByID?ID=20172&small=false"
    },
     "aps": {
        "alert": "Test sound",
        "sound": "default"
    }
}

and message body is sent to https://android.googleapis.com/gcm/send and I added Authorization header too

I get this response which seems that it is successfully send

{
  "multicast_id": 8274120161334065660,
  "success": 1,
  "failure": 0,
  "canonical_ids": 0,
  "results": [
    {
      "message_id": "0:1469587652158787%6878262ff9fd7ecd"
    }
  ]
}

I have tried with both "gcmSandbox" true and false, I get different tokens for both, and for both response is success=1 but no notification appears

Cordova 6.0
ios-cordova 4.2.0

@RezaRahmati RezaRahmati changed the title Notification is not shown on ios Notification is not shown on ios device Jul 27, 2016
@Deadsoil
Copy link

I'm having a somewhat similar issue.... My personal device is receiving notifications but no one else in my team receives them. Their devices register and the notifications successfully send but they never appear on their phones.

@RezaRahmati
Copy link
Author

@Deadsoil is issue solved for your team mates?

@adrinavarro
Copy link

We're seeing the same issue here, with 1.8.0. We're testing with earlier versions at this moment.

@RezaRahmati
Copy link
Author

RezaRahmati commented Jul 27, 2016

I have found the problem and it's described in below link, now it works fine for me

[http://stackoverflow.com/questions/32690850/google-cloud-messaging-showing-success-message-but-not-sending-ios](reason and solution)

{

    "to":"xxx",
    "notification": {
    "sound": "default",
    "badge": "2",
    "title": "default",
    "body": "Test Push!",
  },
   "priority" : "high",
}

@Deadsoil
Copy link

@RezaRahmati - Issue is still not resolved. I already had the priority as high.

The strange thing is I receive them on my device but my team members don't. Even though the console log from my node app tells me it was successfully sent and their devices are registering and returning a token.

It doesn't really make a whole lot of sense.

I might try reverting to an older version of this plugin and see if it resolves the issue. Still doesn't account for why they are working for me and not them though.

It's working for me on an iPhone5s and iPhone6s.... But not for them on a 6s and a 6+. Maybe an ios version issue.

@macdonst
Copy link
Member

@RezaRahmati when sending to GCM on Android use:

{  "to":"l20a0f4EPMw:APA91bEQnIO9AIrLTW6hr8es4EFnMy6iWQQMQdrJAgG0g6Br4etu357sRn8tGJAulSFHuDXY81HDmMl4-nc6Ou0zJcOZmzSEGc3YeD2zU67bpqOYmBsk80AnJTzJXstHS_FlE-0fFR1p",
    "data": {
        "title": "Large Icon",
        "message": "Loaded from assets folder",
        "image": "www/images/daivatech.png",
        "soundname": "default",
        "style": "picture",
        "summaryText": "There are %n% notifications",
        "picture": "http://jarchee.ca/api/Post/GetThumbnailByID?ID=20172&small=false"
    }
}

when sending to GCM on iOS use:

{
"to":"l20a0f4EPMw:APA91bEQnIO9AIrLTW6hr8es4EFnMy6iWQQMQdrJAgG0g6Br4etu357sRn8tGJAulSFHuDXY81HDmMl4-nc6Ou0zJcOZmzSEGc3YeD2zU67bpqOYmBsk80AnJTzJXstHS_FlE-0fFR1p",
    "notification": {
        "title": "Large Icon",
        "body": "Loaded from assets folder",
        "icon": "www/images/daivatech.png"
    }
}

advanced features like picture type messages are not supported on iOS.

@RezaRahmati
Copy link
Author

@macdonst Yes, as I mentioned even after changing message json to "notification" for ios, still I didn't received notification, until I add "priority: high" to message

@RezaRahmati
Copy link
Author

@Deadsoil Could it be "gcmSandbox" problem? all of you are using same ipa file? I mean debug or release mode.

@macdonst
Copy link
Member

@RezaRahmati weird, there should be no reason why it wouldn't show up without priority set to high.

@Setra-Esokia
Copy link

Hi guys

I have same problem, I'm using "gcmSandbox" and add "priority: high" to message. Can you help me please.

Thanks

@RezaRahmati
Copy link
Author

@Setra-Esokia Do you see "sucess:1" in results?

@Setra-Esokia
Copy link

yes, I have sucess:1 but not receive notification

@RezaRahmati
Copy link
Author

@Setra-Esokia Can you put your message json and result json here?

@Setra-Esokia
Copy link

message json => {"message":"congratulations","content-available":"1","priority":"high"}

result json = {"multicast_id":7264988913802171027,"success":2,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1470836861750262%b3dcc6a7f9fd7ecd"},{"message_id":"0:1470836861652114%b3dcc6a7f9fd7ecd"}]}

@RezaRahmati
Copy link
Author

RezaRahmati commented Aug 10, 2016

@Setra-Esokia message should be something like

{
    "to":"xxx",
    "notification": {
        "sound": "default",
        "title": "default",
        "body": "Test Push!",
  },
   "priority" : "high",
}

@Setra-Esokia
Copy link

When I used this structure i have a failure with message "InternalServerError".

{"to":"xxx","notification":{"sound":"default","title":"default","body":"Test Push!"},"priority":"high"}

{"multicast_id":8572784144255206972,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InternalServerError"}]}

@RezaRahmati
Copy link
Author

@Setra-Esokia As a rough guess, Did you connect GCM to APN? I don't remember the exact steps but you need to upload provisioning profile to GCM, so you will get GCM id (instead of APN) and behind the scene GCM send messages to APN

@Setra-Esokia
Copy link

@RezaRahmati Yes, i generate my developper and production certificate and upload this in google service GCM. I receive the valid APNS and GCM token. I have no idea why GCM push failed.

@Assylkhan
Copy link

Hi @RezaRahmati and @Setra-Esokia. Did you solve the issue? If so, could you tell how? Thank you.

@Setra-Esokia
Copy link

Hi @Assylkhan , i have not solve this problem. I have change my plugin with firebase and reconfigure all inside my application.

@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants