Get Device Token

Comments

4 comments

  • Avatar
    Dmitry Dyudeev

    Hello,

    Unfortunately, at the moment there is no method to retrieve the device's out-of-the-box. Thank you for pointing it out! We will definitely add it in one of our next updates.

    As for now, you can use the following workaround:

    pushnotifications.pushNotificationsRegister("Google_project_number", "AppID", {
         //NOTE: all the functions fire on the background thread, do not use any UI or Alerts here
         success:function(e)
         {
             Ti.API.info('TITAIUM!!! JS registration success event: ' + e.registrationId);
    
             //you can save the push token there: e.registrationId
         },
         error:function(e)
         {
             Ti.API.error("TITAIUM!!! Error during registration: "+e.error);
         },
         callback:function(e) //called when a push notification is received
         {
             Ti.API.info('TITAIUM!!! JS message event: ' + JSON.stringify(e.data));
         }
    });
    

    Later, you can send the saved value to your servers.

  • Avatar
    Francisco

    That would be perfect.

    I'm trying the code you wrote, but the line "Ti.API.info('TITAIUM!!! JS registration success event: ' + e.registrationId)" on success function is never called/displayed on console, what could it be?

    success:function(e) { Ti.API.info('JS registration success event: ' + e.registrationId); Ti.App.Properties.setString('PushWooshToken',e.registrationId); setTimeout(function(){ alert(Ti.App.Properties.getString('PushWooshToken')); },30000); },

    Note I added a "Ti.App.Properties.setString('PushWooshToken',e.registrationId);" on the sucess function, and an alert on a 30seg timeout to show the token getted, but my console response is:

    module is => [object Object]

    [INFO] : I/System.out: App ID: XXXXX-XXXXX

    [INFO] : I/System.out: Project ID: XXXX[WARN] : Pushwoosh: Request manager: Try To sent: applicationOpen

    [INFO] : Choreographer: Skipped 184 frames! The application may be doing too much work on its main thread.

    [WARN] : TiVerify: (Timer-0) [4890,5011] Verifying module licenses..

    [WARN] : Pushwoosh: Request manager: PushWooshResult: {"status_code":200,"status_message":"OK","response":null}

    [WARN] : Pushwoosh: Request manager: applicationOpen response success

    [INFO] : TiVerify: (Timer-0) [3862,8873] Succesfully verified module licenses

    [INFO] : GCMIntentService: Device registered: regId = APA91bE_K4ws8JaIa0g****

    [WARN] : DeviceRegistrar: Registering for pushes

    [WARN] : Pushwoosh: Request manager: Try To sent: registerDevice

    [WARN] : Pushwoosh: Request manager: PushWooshResult: {"status_code":200,"status_message":"OK","response":null}

    [WARN] : Pushwoosh: Request manager: registerDevice response success

    [WARN] : DeviceRegistrar: Registered for pushes: APA91bE_K4ws8JaIa0g****

    [INFO] : ALERT: (KrollRuntimeThread) [23046,29050] null

  • Avatar
    Dmitry Dyudeev

    Hello,

    I am glad to inform you that we have just made an update of our Titanium module, which includes methods to retrieve push token and HWID. We are currently testing it. Please contact us if you would like to participate in testing, and I can send the module to you.

  • Avatar
    Francisco

    Great! Where can I download the updated files? I tried from https://github.com/Pushwoosh/pushwoosh-sdk-samples/tree/master/Appcelerator-Titanium/Android-Titanium-Sample, but nothing new until 2 days ago, or nothing added on documentation. Thanks!

Please sign in to leave a comment.