wallyb
Posts: 0
Joined: Mon Sep 02, 2013 5:27 pm

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

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];
    }
Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

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

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

wallyb
Posts: 0
Joined: Mon Sep 02, 2013 5:27 pm

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

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

Return to “Issues”