将onesignal Playerid存储到变量(ionic v1)

时间:2018-08-02 04:18:27

标签: javascript angularjs ionic-framework onesignal

我可以控制台记录玩家ID,但是无法存储在变量中,我想知道如何处理它?<​​/ p>

2018-08-02 12:11:19.246673+0800 [1190:62191] Player ID:undefined
2018-08-02 12:11:19.289098+0800 (Player id)xxxxx-xxxx-xx-xx-xxxx

JavaScript:

$ionicPlatform.ready(function() {
  var notificationOpenedCallback = function(jsonData) {
    console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
  };

  window.plugins.OneSignal
    .startInit("XXXXXXXXX")
    .handleNotificationOpened(notificationOpenedCallback)
    .endInit();
  window['plugins'].OneSignal.getIds((id) => $localStorage.uuid = id.userId);
  console.log("Player ID:" + $localStorage.uuid);
  window['plugins'].OneSignal.getIds((id) => console.log(id.userId));
})

0 个答案:

没有答案