gonzaloaune / GCMPushPlugin

Push notifications for Cordova (GCM & Native support)
MIT License
37 stars 20 forks source link

Push Notification Not Receiving on iOS (GCM) #4

Open aneesv opened 9 years ago

aneesv commented 9 years ago

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

gonzaloaune commented 9 years ago

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.

aneesv commented 9 years ago

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

scripterkaran commented 9 years ago

+1 having same issue

scripterkaran commented 9 years ago

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.

gonzaloaune commented 9 years ago

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

scripterkaran commented 9 years ago

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

gonzaloaune commented 9 years ago

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.

InViZz commented 9 years ago

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" }

scripterkaran commented 9 years ago

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 ")

gonzaloaune commented 9 years ago

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

Vahn84 commented 9 years ago

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

<?php

                // API access key from Google API's Console
                define( 'API_ACCESS_KEY', 'AIzaSyCsnHRL2XHSK13OOj5O0cXbVqePbu4WGVU' );

                $registrationIds = array("muM0qrYW_D8:APA91bGqsN4Vs_218K-Nd8THUJgxVXymNyiRO-OqiaMNppWdC1SqPIismG0zbBjh8oiHO22_aJ6oVv8eNczNvsD6gPRg0bzGxKgXu7Y1AfSrNL0Z4uPZ2liVKFRLP935fUUXBtgvK-XL" );

                // prep the bundle
                $msg = array
                (
                    'message'       => '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

aneesv commented 9 years ago

Notification is reciving when priority is set to "high"

scripterkaran commented 9 years ago

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".

Vahn84 commented 9 years ago

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

aneesv commented 8 years ago

@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 ?

malah-code commented 8 years ago

I think this scenario means that you have something wrong with certification. On Jan 8, 2016 12:54 PM, "Mohammed Anees v" notifications@github.com 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 .

turbobuilt commented 8 years ago

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.
soufianeEssabbane commented 8 years ago

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

AhmAbdallah commented 8 years ago

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};
janbjelicic-sunhill commented 8 years ago

@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.

lunkadbhushan commented 8 years ago

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); -->
        );
turbobuilt commented 8 years ago

@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

soufianeEssabbane commented 8 years ago

@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

Hadevs commented 8 years ago

yes, that fixed my problem, thank you)

2016-09-01 19:34 GMT+03:00 Soufiane notifications@github.com:

@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 .