OneSignal-iOS-SDK icon indicating copy to clipboard operation
OneSignal-iOS-SDK copied to clipboard

[question]: Player ID not being captured on Real Device

Open Gladiatornoshield opened this issue 2 years ago • 2 comments

How can we help?

How do i make sure i capture player ID on real ios device. My code works as expected on a simulator. But when testing on a real device i get null for the player ID(userId).

I am using Ionic:

Ionic:

Ionic CLI : 6.20.1 Ionic Framework : @ionic/angular 5.9.4 @angular-devkit/build-angular : 12.2.18 @angular-devkit/schematics : 12.1.4 @angular/cli : 12.1.4 @ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 3.6.0 @capacitor/android : 3.2.3 @capacitor/core : 3.6.0 @capacitor/ios : 3.6.0

Cordova:

Cordova CLI : 11.0.0 Cordova Platforms : none Cordova Plugins : no whitelisted plugins (0 plugins total)

Utility:

cordova-res : 0.15.4 native-run : 1.6.0

System:

NodeJS : v16.4.2 npm : 8.12.2 OS : macOS Monterey Xcode : Xcode 13.4 Build version 13F17a

import OneSignal from 'onesignal-cordova-plugin';

OneSignal.getDeviceState(function (identity){
 console.log('User Identity: ' + JSON.stringify(identity));
 this.setSessionObject(identity);
});

async setSessionObject(identity) {
 await Storage.set({
   key: 'onesignal',
   value: JSON.stringify({
     player_id: identity.userId,
     push_token: identity.pushToken

   })

 });
}

async getUserSessionObject()
{
 const ret = await Storage.get({ key: 'onesignal'});
 const signal = JSON.parse(ret.value);

 this.player_id = signal.player_id;
 this.push_token = signal.push_token;
}
async registeroneSignal(){

 const ret = await Storage.get({ key: 'user'});
 const user = JSON.parse(ret.value);
  
       let body = {
         "user_id": user.user_id,
         "player_id": this.player_id,
         "push_token": this.push_token
       }; 
    
      
       this.http.post('https://subdomain.domain.com/Authenticate/registeronesignal', body)
       .subscribe(data => {
       
         console.log(data);

        }, error => {

         console.log(error);

      
       });

      
 }

This logic works well on android and on IOS simulator. On real device i get null for player ID even though on the onesignal dashboard the device is subscribed. Not sure if there is something i missed

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Gladiatornoshield avatar Aug 05 '22 04:08 Gladiatornoshield

@Gladiatornoshield Thank you for reaching out I apologize for the late response. It looks like you are using the OneSignal-Cordova-SDK not the iOS SDK. Are you still experiencing this issue?

emawby avatar Sep 15 '22 17:09 emawby

Downgraded to version 2.11.4 - it works perfectly on this version. Thank you

Gladiatornoshield avatar Sep 15 '22 17:09 Gladiatornoshield