Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marchbold/d41ab7b384775cba6706 to your computer and use it in GitHub Desktop.
Save marchbold/d41ab7b384775cba6706 to your computer and use it in GitHub Desktop.
Registering for notifications using the Push Notifications ANE
PushNotifications.init( APP_KEY );
if (PushNotifications.isSupported)
{
PushNotifications.service.addEventListener( RegistrationEvent.REGISTERING, registeringHandler );
PushNotifications.service.addEventListener( RegistrationEvent.REGISTER_SUCCESS, registerSuccessHandler );
PushNotifications.service.addEventListener( RegistrationEvent.REGISTER_FAILED, registerFailedHandler );
PushNotifications.service.addEventListener( RegistrationEvent.ERROR, errorHandler );
PushNotifications.service.register();
}
...
private function registeringHandler( event:RegistrationEvent ):void
{
trace( "Registration started" );
}
private function registerSuccessHandler( event:RegistrationEvent ):void
{
trace( "Registration succeeded with ID: " + event.data );
var deviceTokenOrRegistrationId:String = event.data;
}
private function registerFailedHandler( event:RegistrationEvent ):void
{
trace( "Registration failed" );
}
private function errorHandler( event:RegistrationEvent ):void
{
trace( "Registration error: "+event.data );
}
// com.distriqt.PushNotifications
@ghoshn598
Copy link

Does the code works for both APNS and GCM?

@marchbold
Copy link
Author

Hi,
Yes the extension works for both APNS and GCM.
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment