Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
- {
- NSLog(@"My token is: %@", deviceToken);
- }
- - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
- {
- NSLog(@"Calling push notification next, my registered token is: %@", deviceToken);
- // Code for phonegap communication - calls this method in PushNotification.m
- PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
- [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
- }
- - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
- NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken:%@", deviceToken);
- DLog(@"didRegisterForRemoteNotificationsWithDeviceToken:%@", deviceToken);
- NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@" <"withString:@""]
- stringByReplacingOccurrencesOfString:@">" withString:@""]
- stringByReplacingOccurrencesOfString: @" " withString: @""];
- NSMutableDictionary *results = [PushNotification getRemoteNotificationStatus];
- [results setValue:token forKey:@"deviceToken"];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:results];
- [self writeJavascript:[pluginResult toSuccessCallbackString:[self.callbackIds valueForKey:@"registerDevice"]]];
- }
- register: function() {
- var pushNotification = window.plugins.pushNotification;
- pushNotification.registerDevice({alert:true, badge:true, sound:true}, function(status) {
- app.myLog.value+=JSON.stringify(['registerDevice status: ', status])+"n";
- app.storeToken(status.deviceToken);
- });
- },
- storeToken: function(token) {
- console.log("Token is " + token);
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement