0

sorry my english! Is there a way to get the value of the storage saved object? What I mean is when I output it in the console it shows [object Promise] but when I output in an alert it shows the string value. Is there a way to save that string value in the storage?

This is my code:

initializeApp() {
  this.platform.ready().then(() => {
    this.statusBar.styleDefault();
    this.splashScreen.hide();

    FCMPlugin.getToken(
      (token) => {
        this.saveToken(token);
      },
      (err) => {
        console.log(err);
      }
    );

    this.onNotification();
  });
}

saveToken(token: string) {
  this.storage.set('token', token);
}

This is the plugin code which returns the token

// GET TOKEN //
else if (action.equals("getToken")) {
  cordova.getActivity().runOnUiThread(new Runnable() {
    public void run() {
        try {
          String token = FirebaseInstanceId.getInstance().getToken();
          callbackContext.success(FirebaseInstanceId.getInstance().getToken());
          Log.d(TAG, "\tToken: " + token);
        } catch (Exception e) {
          Log.d(TAG, "\tError retrieving token");
        }
      }
    });
t.niese
  • 39,256
  • 9
  • 74
  • 101
Ace
  • 469
  • 1
  • 7
  • 17
  • I think that the function `JSON.stringify( nameOfSomeObject );` might help you. If there are any circular structures, then you might have to check out this link: https://stackoverflow.com/questions/10392293/stringify-convert-to-json-a-javascript-object-with-circular-reference. – Sean Letendre Aug 10 '17 at 04:35
  • this.storage.get('token') – KAngel7 Aug 10 '17 at 04:36
  • 1
    Where is the point in your code that you are outputting the token to the console? – Shaun Luttin Aug 10 '17 at 05:10

0 Answers0