Android Push Notifications

Greetings! My name is Richard Makhaya. I’m having some difficulty with android push notifications. Having read the tutorial I made sure to download the google play service as well as android support libraries and updated the .unoproj file to include the “Fuse.PushNotifications” package and addded:

“Android”: {
“GooglePlay”: {
“SenderID”: “fuseproject-140513”
}
}

where fuseproject-140513 is my project ID from the google developer’s console. I also made sure that the cloud messaging service was enabled. But woe is me… The javascript code to detect push events does not even fire any events. i.e:

var push = require(“FuseJS/Push”);

    push.onRegistrationSucceeded = function(regID) {
        registrationMessage = "Reg Succeeded: " + regID;
    };

    push.onRegistrationFailed = function(reason) {
        registrationMessage = "Reg Failed: " + reason;
    };

    push.onReceivedMessage = function(payload) {
        registrationMessage = "Reg Failed: " + reason;
    };

Not even the push.onRegistrationFailed event fires. I tried it using the local preview as well as android preview. Is there any place I went wrong?

Hey Bahle,
one thing you’ve definitely done wrong is the sender ID. You have to find and use the project number (11 digits). Reference: http://stackoverflow.com/questions/11294602/android-gcm-sender-id-how-to-get-it

Tried that, I used the project number instead of the project id but it still doesn’t receive any push events.

Another thing I might suggest based on my experience is - when you launch device preview on Android, close the app by clicking the hardware home button, then reopen it from recent apps screen.

I’m not entirely sure why, but sometimes the app wouldn’t register with GCM upon the first launch, while the second launch usually fires everything just fine.

And if that doesn’t help, try killing the preview from recent apps screen, then restart it from the device again, simply by launching the “App (preview)” application that will have been installed there when you ran the preview.

All of that said, push notifications obviously only work on an actual device.

Alright, I’ll keep trying, no luck so far but I’ll keep updating as to progress made. Thanks a million for the timely assistance :slight_smile:

Hi Uldis,

I am trying to find any reference “How-to” for Push notifications. Can You please give me any example (raw) of files .ux and .unoproj
I followed this https://www.fusetools.com/docs/fuse/pushnotifications/push but could not make it work. I downloaded one of example apps and tried to implement it into. Here is my unoproj file:

{
  "RootNamespace":"",
  "Packages": [
  	"Fuse",
  	"FuseJS",
    "Fuse.PushNotifications"
  ],


  "Includes": [
    "*",
    "Assets/Authors/*.jpeg:Bundle",
    "Assets/Images/*.jpg:Bundle"
  ],
  "Android": {
    
    "GooglePlay": {
        "SenderID": "1234567891011"
      }
   
  }
}

And I just pasted javascript example from https://www.fusetools.com/docs/fuse/pushnotifications/push into my ux file.
When I run app on my phone it crashes.
Thanks in advance.

Hi Solomun,

here is a community package that implements the basic push notification support: https://github.com/cubissimo/FusePushExample

If your app crashes, I suggest you create a new forum thread with all information, including any errors thrown. It may be completely unrelated to push notifications, so it doesn’t fit here in this thread.

Hi Uldis,

That’s it! This works. This is my first app and more important it works. I just need to learn and understand the basics. Thanks.