I need to get the "Device Token" to store it on my app and sent individual notifications from server later.

On the following "documentation", there is no doc about how to obtain this Device Token: http://www.pushwoosh.com/appcelerator-titanium-android-push-notification/ http://www.pushwoosh.com/programming-push-notification/android/android-additional-platforms/appcelerator-titanium-integration/

Anybody knows how to get the Device Token on Android? On iOS, getting the token is easy: Ti.Network.remoteDeviceUUID. I tried to use Ti.platform.id, but it returns a small string, when in console it shows a big big string like "APA91bHheaS3S9pBE4jte4jkH..."

UPDATE:

Module shows this Token on console. I need to get it calling it like "pushnotifications.regId", for example.

[WARN] : Pushwoosh: Request manager: registerDevice response success [WARN] : DeviceRegistrar: Registered for pushes: APA91bHheaS3S9pBE4jte4jkHHbxtf...

asked 15 Jul '14, 13:02
fcjurado's gravatar image

fcjurado
2115

edited 15 Jul '14, 13:11

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.

permanent link
answered 18 Jul '14, 09:40
Dmitry%20%20Dyudeev's gravatar image

Dmitry Dyudeev
3.7k7

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

permanent link
answered 22 Jul '14, 07:52
fcjurado's gravatar image

fcjurado
2115

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.

(23 Jul '14, 11:21) Dmitry Dyudeev Dmitry%20%20Dyudeev's gravatar image

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!

(23 Jul '14, 11:46) fcjurado fcjurado's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×49
×30

question asked: 15 Jul '14, 13:02

question was seen: 7,545 times

last updated: 23 Jul '14, 11:46