Adobe Air Push Notifications Not Working Anymore?
I had success using Urban Airship to add device tokens and send push notifications so I moved on to another part of the project. Now during final testing it doesn't work anymore.
I can't seem to register new device tokens. I even have tried a brand new test project with no luck. Has something changed I'm unaware of? Here is the code to the simple test project that doesn't work. It seems as though RemoteNotificationEvent.TOKEN never fires. RemoteNotifier.subscribe does fire properly and there is a prompt on the device to enable push notifications but tokenHandler just doesn't trigger. I added a simple callback at the beginning of tokenHandler and nothing ever happened. Any ideas?
private function onAdded(e:starling.events.Event):void {
var preferredStyles:Vector.<String> = new Vector.<String>();
preferredStyles.push(NotificationStyle.ALERT, NotificationStyle.SOUND);
var subscribeOptions:RemoteNotifierSubscribeOptions = new RemoteNotifierSubscribeOptions();
subscribeOptions.notificationStyles = preferredStyles;
var remoteNotifier:RemoteNotifier = new RemoteNotifier();
remoteNotifier.addEventListener(RemoteNotificationEvent.TOKEN, tokenHandler);
if (RemoteNotifier.supportedNotificationStyles.toString() != "") {
remoteNotifier.subscribe(subscribeOptions);
}
}
public function tokenHandler(e:RemoteNotificationEvent):void {
var urlReq:URLRequest = new URLRequest(new String("https://go.urbanairship.com/api/device_tokens/" + e.tokenId));
urlReq.authenticate = true;
urlReq.method = URLRequestMethod.PUT;
URLRequestDefaults.setLoginCredentialsForHost("go.urbanairship.com", "secret", "secret");
var urlLoad:URLLoader = new URLLoader();
urlLoad.load(urlReq);
}