GCMPushPlugin icon indicating copy to clipboard operation
GCMPushPlugin copied to clipboard

Push Notification Not Receiving on iOS (GCM)

Open aneesv opened this issue 9 years ago • 24 comments

While sending push notification GCM response with success

{
    "multicast_id": 8622691452730618000,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": [
        {
            "message_id": "0:1440615884059435%3ed3b4de3ed3b4de"
        }
    ]
}

but notification is not receiving

aneesv avatar Aug 26 '15 19:08 aneesv

Can you setup a breakpoint on the didReceiveRemoteNotification method and see if it goes through there once you receive the notification?, that will tell us if you are not receiving it at all or the code is not actually working. Thanks.

gonzaloaune avatar Aug 26 '15 19:08 gonzaloaune

I have tried its not going through didReceiveRemoteNotification so i think notification is not receiving at all

aneesv avatar Aug 27 '15 10:08 aneesv

+1 having same issue

scripterkaran avatar Sep 14 '15 06:09 scripterkaran

A more detailed result 1# When app is running, we do get notification 2# When app is in background , we seldom get notification 3# when app is quit, we never get notification 4# when iphone is restarted: we never get any notification unless we open the app.

Testing on Iphone 5s ios 7.1.2 and ipad ios 8.0.

scripterkaran avatar Sep 15 '15 10:09 scripterkaran

That's much more helpful, I will review during the weekend, I'm kind of busy lately. Thanks!

gonzaloaune avatar Sep 15 '15 14:09 gonzaloaune

I think its GCM problem : check this https://github.com/googlesamples/google-services/issues/60

scripterkaran avatar Sep 16 '15 06:09 scripterkaran

Well, I'm pretty sure I tried all the possible push notifications scenarios while developing the plugin, in any case I will definitely take a look this weekend.

gonzaloaune avatar Sep 16 '15 12:09 gonzaloaune

had the same problem. fix it by adding "priority": "high" to push message: { "registration_ids": ["nYG2y3HGY3...TSR-i3KWNqI"], "notification": { "title": "Hello, world!", "body": "a", "badge": 3, "sound": "default" }, "priority": "high" }

InViZz avatar Sep 21 '15 12:09 InViZz

That doesn't seem like a better option. I mean, what if we don't have control of the server? What if we don't have control of what we are to send (I am thinking in "production environment ")

scripterkaran avatar Sep 21 '15 13:09 scripterkaran

I think @InViZz refers as priority as the GCM option: https://developers.google.com/cloud-messaging/http-server-ref

gonzaloaune avatar Sep 21 '15 14:09 gonzaloaune

this doesn't work for me.

Android receives succesfully the notification...but nothing happens on iOs device. From my log i can see the registration token but when i use it with my test i cannot make it work

this is the php that i use for testing notifications

'here is a message. message', 'title' => 'This is a title. title', 'subtitle' => 'This is a subtitle. subtitle', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here' ); // prep the bundle $notification = array ( "body" => "This week’s edition is now available.", "title" => "NewsMagazine.com", ); $fields = array ( 'to' => 'muM0qrYW_D8:APA91bGqsN4Vs_218K-Nd8THUJgxVXymNyiRO-OqiaMNppWdC1SqPIismG0zbBjh8oiHO22_aJ6oVv8eNczNvsD6gPRg0bzGxKgXu7Y1AfSrNL0Z4uPZ2liVKFRLP935fUUXBtgvK-XL', 'priority' => 'high', 'content_available' => true, 'notification' => $notification, 'data' => $msg ); $headers = array ( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://gcm-http.googleapis.com/gcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result; ?>

the weird thing, is that this works ok with android. With iOs not only i'm not receiving any notification, but after some tests, it says that the token is invalid (but the token from the log it's still the same as before)

Any help would be really appreciated...i don't what to do

Vahn84 avatar Sep 29 '15 15:09 Vahn84

Notification is reciving when priority is set to "high"

aneesv avatar Oct 01 '15 16:10 aneesv

also, its a hack around. iOS allows only certain numbers of push notifications to be sent to a device with priority high. Its affects the battery. So, you might don't want to use "priority: high".

scripterkaran avatar Oct 02 '15 05:10 scripterkaran

anyone can tell me if there are any erorrs in my PHP?

Vahn84 avatar Oct 02 '15 06:10 Vahn84

@gonzaloaune Push notification is working fine (when using priority hight) while testing app on Xcode. But when uploaded to store and testing with testflight first gcm request is success (No notification) after that all request show error("error": "NotRegistered")

Any idea why this is happening ?

aneesv avatar Jan 08 '16 17:01 aneesv

I think this scenario means that you have something wrong with certification. On Jan 8, 2016 12:54 PM, "Mohammed Anees v" [email protected] wrote:

@gonzaloaune https://github.com/gonzaloaune Push notification is working fine (when using priority hight) while testing app on Xcode. But when uploaded to store and testing with testflight first gcm request is success (No notification) after that all request show error("error": "NotRegistered")

Any idea why this is happening ?

— Reply to this email directly or view it on GitHub https://github.com/gonzaloaune/GCMPushPlugin/issues/4#issuecomment-170073772 .

malah-code avatar Jan 08 '16 18:01 malah-code

I got this warning in the console while running the application. It seems relevant:

[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:],
but you still need to add "remote-notification" to the list of your supported UIBackgroundModes
in your Info.plist.

turbobuilt avatar Feb 08 '16 14:02 turbobuilt

There's something very wrong with gcm in production environment it's kind of frustrating, setting up the development works like a charm, you get notifications in and out the app. but once I move to the production environment i get "unregistered" error with no explanations ... even if you set _registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:@NO}; :s :s

soufianeEssabbane avatar Feb 13 '16 07:02 soufianeEssabbane

Set "priority": "high"

{
      "to": "gcm_device_token",
      "priority": "high",
      "content_available": false,
      "notification": {
        "sound": "default",
        "badge": "1",
        "title": "Push Title",
        "body": "Push Body"
      }
    }

Here's the code to use for production environment : appDelegate.m

  _registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@NO};

Here's the code to use for development environment : appDelegate.m

 _registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                             kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};

AhmAbdallah avatar Apr 20 '16 09:04 AhmAbdallah

@soufianeEssabbane Do you still have the same problem, I'm experiencing the same thing. Everything works in the dev setup but after I want to try it in the production setup notregistered error message is returned and that's it.

janbjelicic-sunhill avatar Sep 01 '16 11:09 janbjelicic-sunhill

This works for me.

 $fields = array(
                'registration_ids' => $registration_ids,
            'data' => $message,  <!-- where $message = array("message" => $message1, 'body' => $message1); -->
        'content-available'  => true,
                'priority'      => 'high',    
                'notification' => $message, <!-- where $message = array("message" => $message1, 'body' => $message1); -->
        );

lunkadbhushan avatar Sep 01 '16 11:09 lunkadbhushan

@soufianeEssabbane You have to set sandbox mode to false. Did you do that? It can be frustrating because if you build and forgot to do that it won't work. Every time you do a test build you have to set it to sandbox mode

turbobuilt avatar Sep 01 '16 16:09 turbobuilt

@dtruel thanks for your feedback, I actually did solve it. But also moved to FCM where it handle the sandbox and prod mode by it self

soufianeEssabbane avatar Sep 01 '16 16:09 soufianeEssabbane

yes, that fixed my problem, thank you)

2016-09-01 19:34 GMT+03:00 Soufiane [email protected]:

@dtruel https://github.com/dtruel thanks for your feedback, I actually did solve it. But also moved to FCM where it handle the sandbox and prod mode by it self

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gonzaloaune/GCMPushPlugin/issues/4#issuecomment-244136486, or mute the thread https://github.com/notifications/unsubscribe-auth/AJq2l5Zga3j7jXlclNSibdFSpyrB5Tgzks5qlv6bgaJpZM4Fyy5X .

Hadevs avatar Sep 01 '16 16:09 Hadevs