Testing Push notifications


#1

Following through the tutorials, I have created an account on GCM and grabbed the SenderID and API key. The docs say that once push notifications have been enabled – which I can confirm they have been – you should make a call to register the device through this:


supersonic.device.push.register ({
      senderID: 1111111111,
      onSuccess:function(data){
        supersonic.logger.log(data);
      },
      onFailure:function(error){
        supersonic.logger.log(error);
      }
 });

N.B. Javascript not Coffeescript like the example in the docs.

This is consistently, regardless of the phone i use, returning the error:

supersonic.device.push.register rejected: {}

I have triple checked the senderID to confirm it is correct. No details are given on the error whatsoever. After checking through google i found a solved issue (https://github.com/AppGyver/PushNotifications/issues/21) that claims resetting the timezone on his phone allowed him to reset and then successfully register and return the DeviceID. After numerous attempts, i can only assume it is not fixing my issue.

I have made a call to unregister, like this:


supersonic.device.push.unregister ({
      senderID: 1111111111,
      onSuccess:function(data){
        supersonic.logger.log(data);
      },
      onFailure:function(error){
        supersonic.logger.log(error);
      }
 });

which yields the same error.

Any help would be great. Other than this – and some teething problems trying to replace angular with Aurelia – I am finding the entire AppGyver package a godsend!

Thanks


#2

No experience with this yet but off the top of my head – should senderID be a string?


#3

Hi, supersonic.device.push is an undocumented and unfinished API.

Please use directly the plugin API described in the README: https://github.com/AppGyver/PushNotifications

You can take a hint from Steroids.js Testapp: https://github.com/AppGyver/steroids-js/blob/4d4f5cf5180a314f29807cb4ad9b2fd0a10d230e/testApp/app/controllers/plugin.coffee#L83


#4

Hi mate!

Here’s the code I’m using to get user’s device token in order to send push notifications:

var pushNotification;
document.addEventListener('deviceready', function()
{
	pushNotification = window.plugins.pushNotification;
	pushNotification.register(
		pushNotificationRegistration,
		pushNotificationError,
		{
			// android options
			'senderID': 'XXXXXXXXXXXX',
			// ios options
			'badge': 'true',
			'sound': 'true',
			'alert': 'true'
		});
	function pushNotificationError(error)
	{
		// if error
	}
	function pushNotificationRegistration(deviceToken)
	{
		// save deviceToken
	}
});

Hope this helps!