Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
Gladiatornoshield opened this issue Aug 5, 2022 · 2 comments
Closed
1 task done

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

Gladiatornoshield opened this issue Aug 5, 2022 · 2 comments

Comments

@Gladiatornoshield
Copy link

Gladiatornoshield commented Aug 5, 2022

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

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Sep 15, 2022

@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?

@Gladiatornoshield
Copy link
Author

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

@emawby emawby closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants