phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Notification not Fires in iOS #631

Open pooya511 opened 8 years ago

pooya511 commented 8 years ago

Hi,

I followed the instruction step by step. Plugin is attached to project successfully and when I open the app it asks for permission. Fortunately I can get registration ID. For server side sender I use APN Tester free. I import certificate (generated in App-ID section of my developer account under development part of Push Notification access) and test it with this paload: {"aps":{"alert":"Hello World!","badge":1}}

I got confused. I don't know where the problem is. I double checked certificate and provisioning profile.

Thanks

matdev commented 8 years ago

Do you send the notification to the device token you get when your push.on('registration',...) event is fired i.e. data.registrationId ?

Do you see the notification in iOS notification center ?

pooya511 commented 8 years ago

Currently i copy paste device reg ID which is 32 characters into apns online tester. I'm want to use APNs directly and not to use CGM because it has limited functionality.

Pooya Sarraf

On Feb 19, 2016, at 6:59 PM, Mathias Caquet notifications@github.com wrote:

Do you send the notification to the device token you get when your push.on('registration',...) event is fired i.e. data.registrationId ?

Do you see the notification in iOS notification center ?

— Reply to this email directly or view it on GitHub.

pooya511 commented 8 years ago

I use following code in my application. I also use development certificate,development provisioning profile and development APNs ssl certificate(I think this is sandbox). I guess the application can't diagnose to use _sandbox _ server and us main server. How can I tell the app to use sandbox?

var push_id;
var push = PushNotification.init({
    "ios": {
        "senderID": "475058352589",
        gcmSandbox: true,
        alert: "true",
        badge: true,
        sound: 'true'
    }
});

push.on('registration', function (data) {
    // send data.registrationId to push service
    push_id = data.registrationId;
    alert(data.registrationId);
});

push.on('notification', function (data) {
    // do something with the push data
    // then call finish to let the OS know we are done
    alert(data);
    push.finish(function () {
        console.log("processing of push data is finished");
    });
});
pooya511 commented 8 years ago

Problem solved. I noticed Bundle Identifier should be as same as provisioning profile like com.something.something2 . That was not on any of documentations and I spent over a week :)

matdev commented 8 years ago

Glad you solved your problem.

For info, you don't need to set the gcmSandbox flag in the ios init section. You tell the app to use sandbox when you set a developement provisioning profile in XCode

macdonst commented 8 years ago

@matdev no, you do have to set the gcmSandbox property. There is code in the PushPlugin that needs that parameter set properly.

barocsi commented 8 years ago

I have set all certs properly. GCMSandbox property is set. Provisioning is development.

When testing manually APNs its working. Only GCM that is not able to peer through. Bundle ID is set properly.

I wonder if this is switched by gcmsandbox:true : https://developers.google.com/cloud-messaging/ios/certs

In your code, make sure that the value of the kGGLInstanceIDAPNSServerTypeSandboxOption option that you are passing to GGLInstanceID.tokenWithAuthorizedEntity:scope:options:handler: is correctly set for the environment that you are using: true for development, false for production. If you are not using the correct environment, messages will not be delivered to your app.```

In cordova I can see that the phone is registering in sandbox mode, I can send message using this:

curl --header "Authorization: key=xxx" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d"{\"registration_ids\":[\"yyy\"], \"collapse_key\": \"Turn\", \"content_available\": true, \"notification\": { \"title\": \"title\", \"body\": \"body\", \"badge\": \"1\" }}```

The response is success.

However the device is not receiving anything.

mathew-kurian commented 8 years ago

@barocsi same situation here

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.