0

I created a Ionic/AngularJS app and I am using PushPlugin for Push Notifications. When I am inside the app and receive a notification I receive it and all works well.

But when I am out of the app and I receive a notification in the notification bar and tap on it I see this in the log file:

  07-01 10:56:51.651: W/ActivityManager(3037): java.lang.SecurityException: 
  Permission Denial: starting Intent { flg=0x24000000 cmp=za.co.vine.gcom.phonegap.test/com.plugin.gcm.PushHandlerActivity bnds=[0,1021][1080,1213] (has extras) } from null (pid=-1, uid=10261) not exported from uid 10275
  07-01 10:56:51.651: W/ActivityManager(3037):  at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1669)
  07-01 10:56:51.651: W/ActivityManager(3037):  at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:977)
  07-01 10:56:51.651: W/ActivityManager(3037):  at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:4182)
  07-01 10:56:51.651: W/ActivityManager(3037):  at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:252)
  07-01 10:56:51.651: W/ActivityManager(3037):  at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:192)
  07-01 10:56:51.651: W/ActivityManager(3037):  at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64)
  07-01 10:56:51.651: W/ActivityManager(3037):  at android.os.Binder.execTransact(Binder.java:404)
  07-01 10:56:51.651: W/ActivityManager(3037):  at dalvik.system.NativeStart.run(Native Method)

I use phonegap build to build the app - Its version 3.4.0

I see some people suggest adding exported=true in AndroidManifest fiel, but I cannot do that with Phonegap build.

Some more log lines from LogCat:

  07-02 11:11:41.846: V/GCMBroadcastReceiver(29009): onReceive: com.google.android.c2dm.intent.RECEIVE
  07-02 11:11:41.851: V/GCMRegistrar(29009): Setting the name of retry receiver class to com.plugin.gcm.CordovaGCMBroadcastReceiver
  07-02 11:11:41.851: V/GCMBroadcastReceiver(29009): GCM IntentService class: com.plugin.gcm.GCMIntentService
  07-02 11:11:41.851: V/GCMBaseIntentService(29009): Acquiring wakelock
  07-02 11:11:41.871: V/GCMBaseIntentService(29009): Intent service name: GCMIntentService-GCMIntentService-1
  07-02 11:11:41.876: D/GCMIntentService(29009): onMessage - context: android.app.Application@42a90348
  07-02 11:11:41.896: W/ApplicationPackageManager(29009): getCSCPackageItemText()
  07-02 11:11:41.931: V/GCMBaseIntentService(29009): Releasing wakelock

And this is my onNotificationGCM code:

  onNotificationGCM = function(e) {
    console.log("gvi.Notifications:onNotificationGCM");

    switch( e.event ) {
        case 'registered':
            if ( e.regid.length > 0 ) {
                // Your GCM push server needs to know the regID before it can push to this device
                // here is where you might want to send it the regID for later use.
                if (self.debug) console.log( 'registration id = '+e.regid );
                pushRegisterSuccessCB( e.regid );
            }
        break;

        case 'message':
            // this is the actual push notification. its format depends on the data model
            // of the intermediary push server which must also be reflected in GCMIntentService.java
            console.log(e);
            if (self.debug) {
                console.log( 'message' );
                console.log( e );

            }
            _retrieveMessages();

            //alert('message = '+e.message+' msgcnt = '+e.msgcnt+' msgid = '+e.msgid+' type = '+e.type);
            if ( e.foreground ) {
                console.log( 'foreground' );

                //var my_media = new Media("/android_asset/www/"+e.soundname);
                //my_media.play();
            }
            else   // otherwise we were launched because the user touched a notification in the notification tray.
            if (e.coldstart) {
                console.log( 'coldstart' );

            }
            else {
                console.log( 'background' );

            }
        break;

        case 'error':
          alert( 'GCM error = '+e.msg );
        break;

        default:
          alert( 'An unknown GCM event has occurred' );
          break;
    }
};

And _retrieveMessages function:

  _retrieveMessages = function() {
    if (self.debug) console.log( "gvi.Notifications:_retrieveMessages" );

    if ( window.device !== undefined ) {
        //self._platform = device.platform === undefined? self._platform: device.platform;
        self._uuid = device.uuid === undefined? self._uuid: device.uuid;
        self._model = device.model === undefined? self._model: device.model;
        self._version = device.version === undefined? self._version: device.version;
    }

    _ajaxGet("/cloudMessaging/Register?" +
              "action=retrieve" +
              "&appid=" + self._appKey +
              "&secretkey=" + self._appSecret +
              "&deviceid=" + self._uuid +
              "&recdate=" + new Date().getTime(),
              _retrieveMessageSuccessCB, 
              function (statusCode, json) {if (self.debug) console.log("_sendReceipt:ERR:" + statusCode +" :"+ JSON.stringify(json, null, 2) )});
};

I have also seen that when people downgrade to phonegap 2.9 it works, but I don't want to do that. How can I fix this?

lulu88
  • 1,694
  • 5
  • 27
  • 41
  • Follow this link steps its working in version 3.4.0 http://stackoverflow.com/questions/23234573/user-push-notifications-in-cordova-3-3/23243014#23243014 – Ved Jul 01 '14 at 12:26
  • I did exactly that. Does not work. – lulu88 Jul 01 '14 at 12:55
  • For android, the payload has to have a "message" field. Try changing the "alert" key to a "message" key. { "message": "hi", ... } – Ved Jul 02 '14 at 04:45
  • Ved, I have that: Message gcmmessage = new Message.Builder() .addData("type", msgType) .addData("message", content) .addData("msgcnt", badgeNumber + "") .addData("sender", affiliateName) .addData("msgid", messageId) .addData("sound", "default") .build(); – lulu88 Jul 02 '14 at 06:55
  • I am talking about server side file – Ved Jul 02 '14 at 09:44
  • _retrieveMessages() what is doing this function? – Ved Jul 02 '14 at 09:52
  • It calls the API on my server to retrieve the message from the server, I will paste that method above as well. – lulu88 Jul 02 '14 at 09:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/56636/discussion-between-ved-and-lulu88). – Ved Jul 02 '14 at 10:02
  • If you've solved this problem I would love to hear how you've resolved it. I have the same problem and I've tried everything I can possibly think of but to no avail. Also using pushplugin 2.1.1, and I was originally on phonegap build 3.3.0 but I've tried everything from 3.0.0 to 3.5.0 (always 3.x.0 tho, never a 3.x.x) – Dastagir Sep 10 '14 at 15:15

0 Answers0