Page 1 of 1

How to copy IOS Push service deviceToken into Appery Local Storage Variable

Posted: Mon Sep 02, 2013 5:27 pm
by wallyb

I want to use the apple IOS push service and am able to send push notifications with a php script if I know the deviceToken for the phone in question. Looking at the Appery generated code I see the didRegisterForRemoteNotificationsWithDeviceToken function and can print out the deviceToken value.
I would like to stuff that value into a Local Storage Variable for display (debug) in my app, and also to send it to the server my app connects to so it can then send push notifications via the Apple Notification Service.

Can someone give me a little java script to copy the deviceToken into a Local Storage Variable? Is there a built-in Appery way to do this?

thanks,
w

#pragma PushNotification delegation

  • (void)application:(UIApplication)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData)deviceToken
    {
    NSLog(@"My token is: %@", deviceToken);
    PushNotification* pushHandler = [self.viewController getCommandInstance:@"PushNotification"];
    [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }

How to copy IOS Push service deviceToken into Appery Local Storage Variable

Posted: Mon Sep 02, 2013 6:32 pm
by Maryna Brodina

Hello! I'll update.


How to copy IOS Push service deviceToken into Appery Local Storage Variable

Posted: Mon Sep 02, 2013 9:03 pm
by Maryna Brodina

localStorage variable "pushNotificationToken" should be created automatically and after "Push Initialize" event is done this localStorage will be filled in with necessary values.


How to copy IOS Push service deviceToken into Appery Local Storage Variable

Posted: Mon Sep 02, 2013 11:34 pm
by wallyb

Thanks Marina, that worked. The "pushNotificationToken" variable does not show up in a list, but I can read it using the getLocalStorage javascript function.

thanks for the quick support.

w