pushNotificationDeviceID not unique on iOS devices

I'm using the following to obtain the device ID:

var deviceID = localStorage.getItem('pushNotificationDeviceID');

I've found that this device ID is unique on Android devices. Although on iOS devices running the same OS version, I've found the device ID is the same for every user of the app.

I've done lots of tests and found that the device ID is not unique on any device running the same app and iOS version.

I'm using this device ID to send push notifications. In my testing, the last iOS device to launch the app is the only recipient when sending push notifications to that device ID. Although other users have the same device ID and have launched the app in the past, only the last person to have launched the app receives the push notification.

Do I also need to obtain their token ID? Will this render a unique ID?

Or how else can this problem be fixed?

Thanks for your help.
1 person has
this problem
+1
This topic is no longer open for comments or replies.
  • Hi Steve,

    Please check the value of device.uuid. Is it unique for different iOS devices?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • So how would I retrieve the device.uuid? Would the following work?:

    var UdeviceID = localStorage.getItem('device.uuid');

    Is the device.uuid stored the same as the pushNotificationDeviceID?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Steve,

    To access deviceID on Device Ready event (Page Load and Page Show won't work) you can use the following JavaScript code:
    device.uuid 
    In Appery.io you can also use:
    PushNotification.getDeviceUniqueIdentifier(); 

    This can be used on device only.

    Here is a nice explanation from Marina: https://getsatisfaction.com/apperyio/...
    This can be helpful also: https://getsatisfaction.com/apperyio/...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • This reply was removed on 2013-12-18.
    see the change log
  • Hi Steve, just to add what Katya said, this is a standard PhoneGap API you can find description in their docs:
    :: http://docs.phonegap.com/en/3.0.0/cor...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • I've done some more testing and things are still not working properly for iOS push notifications.

    On Android,

    using: var deviceID = localStorage.getItem('pushNotificationDeviceID');

    My Android device ID is = 99000206643728;b7ad5277e66329d7

    using: var deviceID = device.uuid;

    My Android device ID is = b7ad5277e66329d7

    (Notice that using "device.uuid" it returns the second half of the full device ID above.)

    Sending a push notification to the Android device ID returned from device.uuid does not work. Although the push notifications to Android devices using 'pushNotificationDeviceID' work properly.

    On iOS,

    using: var deviceID = localStorage.getItem('pushNotificationDeviceID');

    My iOS device ID is = 8543e25880689e0899f4a1dd3c85bc29

    using: var deviceID = device.uuid;

    My iOS device ID is = 18B011BA-C4DE-45DB-8482-F01FC780

    Sending a push notification to the device ID returned from device.uuid does not work.

    I've tried the app with three different iOS devices running iOS7. All iOS devices return the same device ID (8543e25880689e0899f4a1dd3c85bc29). I can send a push notification to that device ID, although only the most recent iOS device to launch the app receives the notifications.

    On the Android side, everything works fine (using 'pushNotificationDeviceID'), but things are not working properly for iOS.

    Illya Stepanov - the link you provided mentioned an iOS quirk, but the description wasn't consistent with the behavior I'm seeing.

    Any advice would be greatly appreciated.

    Thanks,

    Steve
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Another update...

    I did a test sending a notification to all devices (no filter) and the notification was only received by the last iOS device (running iOS7) to launch the app. Android devices worked just fine though.

    So apparently there's also an issue registering the iOS devices (running iOS7) with the Appery Push Notification system? Is there a way to see how many devices are registered for each app in the Push Notification area?

    Any help is greatly appreciated.

    Thanks!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Hello! Yes, looks like that http://community.phonegap.com/nitobi/...
    What Libraries version you use? Set it to 1.2 if you have another one.
    Is there a way to see how many devices are registered for each app in the Push Notification area?
    sure, in DB connected to app in Devices collection you can see all registered apps and deviceIDs. Try to test the following way - clear the table, install app on device, check Devices table. Install app on another device. Check Devices table again - is there new record added? Check what deviceIDs are there? Let us know result.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Maryna,

    Thanks for the reply.

    Here's what happened in my testing using iOS7 devices.

    The device ID is recorded properly for the first iOS7 device to launch the app. Although for the second iOS7 device to access the app, it doesn't add a new record but only updates the time stamp on the previous record. Apparently this is an issue related to iOS7 devices? Android and other iOS version devices behave properly.

    It appeared that I was using the 1.0 library. I've updated the library to 1.2 although I won't be able to test on iOS7 devices until I deploy on the Apple App store. I can't test on iOS7 devices right now since the Appery Xcode export is not yet compatible with Xcode5. In another post, you mentioned that the January release will be compatible with Xcode5.

    I'll follow up later to determine if the Library 1.2 has an impact on the problem.

    Thanks!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Ran into a snag...

    After changing my library to 1.2, the

    window.plugins.childBrowser.showWebPage(the_link);

    no longer works. I really need the childbrowser functionality on iOS. Any suggestions?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • I had wanted to have the ability to go back to the app on iOS and that's not possible with the straight "window.open" command. It opens the URL, but there's no way to go back on iOS. With the childbrowser, there was a "Done" button that allowed the user to go back.

    Any way to get the ability to go back from the URL on iOS?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • My bad. I was using the window.open('http://apache.org'); without the '_blank' argument. The following works fine for me now:

    window.open('http://apache.org', '_blank', 'location=yes');

    Thanks for the help!

    Steve
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • After updating to library 1.2, the iOS device ID is now working properly! Yeah!

    Although updating to library 1.2 introduced a new problem. My facebook login no longer works. I'm in the middle of debugging the problem and I've found that the "code" returned from Facebook is working, but the "token" is no longer functioning.

    If you have a quick suggestion to fix this problem, it would save me some time. Thanks!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Hello! Could you clarify what do you mean on ""token" is no longer functioning"? Is there any error?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • The Facebook login procedure per the tutorial requires the exchange of a code returned from Facebook for a Facebook token (see the section in the tutorial titled "Exchange the code for a user access token").

    In my debugging, the Facebook code is still being retrieved (although it uses another option since the childbrowser isn't there anymore with library 1.2), but the portion that retrieves the Facebook token isn't working anymore.

    If you have any suggestions, that would be great. Otherwise I'll slog through it to find out the problem caused by switching to library version 1.2.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • I found the problem, but I'm not sure how to solve it.

    Here's what's going on...

    1. Before I initiate the Facebook login, I store a needed local storage variable.
    2. The Facebook code calls Facebook via the window.open command where the user logs into Facebook. The Facebook call has the return URL to the next page of my app (sending the user back to my app after succesful login).
    3. Everything works for the Facebook login, but when the return URL takes the user back to the app, my local storage variable (created in step 1) is gone.

    Got any suggestions?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Hello! The issue is that if you don't have ChildBrowser you just use
    window.open(url);
    that means you load Facebook site instead your app then do redirect not to the app, but to the test page
    http://appery.io/app/view/34228ef6-xxxx-xxxx-xxxx-xxxxxxxxxxx/FacebookLogin.html
    so it's not your app opened after redirect from Facebook, but app preview. To avoid it instead
    window.open(url);
    you should open url in InAppBrowser and do the same as with ChildBrowser. For example
    var ref = window.open(url, '_blank', 'location=no');
    ref.addEventListener('loadstart', function(event) {
    if(event.url.indexOf(redirectUrl) === 0) {
    /* if user successfully logged in */
    ref.close();
    var vars = parseUrlVars(event.url);
    localStorage.setItem('code', vars.code); /* store secret code */
    Appery.navigateTo('FacebookLogin', {reverse: false}); /* Navigate to page 'result' */
    }
    });
    • Can you help me out a bit more with where this code should go (what it should replace)? Based on the current tutorial the click event for the 'Connect to Facebook' button is:


      /* Script to oAuth to Facebook app */
      var redirectUrl = 'http://appery.io/app/view/dcxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resultsFacebook.html';

      var url = 'https://www.facebook.com/dialog/oauth?client_id=xxxxxxxxxxxxxxxxx';
      url += '&redirect_uri=' + redirectUrl;
      url += '&scope=basic_info,user_photos,user_status,friends_photos,friends_status';
      url += '&state='+OAuth.nonce(17);

      var cb = null;
      if(window.plugins) {
      cb = window.plugins.childBrowser;
      }
      if (cb != null) {
      /* When native childBrowser plugin must be used to navigate to facebook. */
      cb.onLocationChange = function (url) {
      if(url.indexOf(redirectUrl) === 0) {
      /* if user successfully logged in */
      cb.close();
      var vars = parseUrlVars(url);
      localStorage.setItem('code', vars.code); /* store secret code */
      Appery.navigateTo('result', {reverse: false}); /* Navigate to page 'result' */
      }
      };

      cb.showWebPage(url);

      }
      else {
      localStorage.setItem('code', '');
      window.open(url);
      };


      I tried to replace from var cb=null through the cb.showWebPage(url); and retain the else statement but no go. I'm about to add an Instagram connection as well but would really like to make sure I'm using the correct InAppBrowser and not redirecting users to the preview page (but to the real app).

      Thanks
    • Hello!

      Try the following code
      var redirectUrl = 'http://appery.io/app/view/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/result.html';
      

      var url = 'https://www.facebook.com/dialog/oauth?client_id=XXXXXXXXXXXX';
      url += '&redirect_uri=' + redirectUrl;
      url += '&scope=user_education_history,friends_education_history,user_work_history,friends_work_history';
      url += '&state='+OAuth.nonce(17);

      if (typeof(cordova) !== "undefined") {
      var ref = window.open(url, '_blank', 'location=yes');
      ref.addEventListener('loadstart', function(event) {
      if(event.url.indexOf(redirectUrl) === 0) {
      /* if user successfully logged in */
      ref.close();
      var vars = parseUrlVars(event.url);
      localStorage.setItem('code', vars.code); /* store secret code */
      Appery.navigateTo('result', {reverse: false}); /* Navigate to page 'result' */
      }
      });
      } else {
      localStorage.setItem('code', '');
      window.open(url);
      };
      please note on device this code should be invoked only after device ready event.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • I’m happy
    Sweet!!! That fixed it!

    Thank You! Thank You!!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • Steve, have you sorted any of these issues. I am having the same problem with the device ID's. And i am using 1.2 library and phonegap 3.0

    Also, are you using xcode 5 with javascript ?
    • I no longer experienced the issue once I changed to the 1.2 version library. Yeah I'm using the phonegap 3.0.0.

      I'm not sure I understand your question regarding the Xcode 5 with javascript. I'm now using Xcode5 to publish the app to iOS and yes the app definitely has javascript. I had problems with the Xcode export into Xcode 5 in the past, but apparently Appery fixed the issue and it now works with Xcode 5.
    • Okay, I had the same issue with different uuid's for iOS which will cause a problem, so will need to change the app design.

      I use Apery and export it as a ipa file, and use iTunes to test it. But i thought you coded your app via xcode.

      Seemed odd that there is much going back and forth to test it, which is why I asked about how you use Xcode.

      But thank you for getting back to me :)
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned kidding, amused, unsure, silly sad, anxious, confused, frustrated