Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

Getting device ID is killing app?

I am attempting to run the following JavaScript when app's start page loads:

codealert(PushNotification.getDeviceUniqueIdentifier());/code

Annnddd.... now my app isn't loading. I just get a spinning AJAX wheel that never goes away. The test app works fine without that line, and does not have any services or other custom JavaScript.

Is that code outdated? It's what the documentation says I should use to get a device ID.

Thanks!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Getting device ID is killing app?

Hello! This is because this variable is not defined when you run this code. You don't need to run this code to retrieve device id, it's stored in pushNotificationDeviceID localStorage. You can retrieve it from localStorage.

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

Getting device ID is killing app?

Thanks for the response!

Unfortunately, it's still not quite working.

codealert(localStorage.getItem('pushNotificationDeviceID'));/code
^ this is returning a null alert message.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Getting device ID is killing app?

Hello! What event you use to run this code? Please try Device Ready event and the following code:
presetTimeout(function(){alert(localStorage.getItem('pushNotificationDeviceID'))}, 1);/pre

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

Getting device ID is killing app?

Hmm, that looks like it's working. Thanks. :) Before, I had it on the page's load event without a timeout.

You're awesome, Marina!

Return to “Issues”