Cordova on resume and native plugins

Hello guys,

I tried to find all the web and I didn’t found anything about this.
I need to use cordova onResume trigger to save the user access into my database but a weird thing is happen.

Only when running in Android it calls every time I call a native plugin (camera, photoview, imagepicker) and return to app. It doesn’t happen when the app is running in IOS and that’s the way I want it to do.

document.addEventListener(‘resume’, () => {
this.saveUserAccess();
});

Anyone know how to fix it behavior at Android?

I’m using Ionic 3 for this app. And developing through a MacOs to Android and IOS.

I appreciate any help with that.

1 Like

I’ve yet to see a situation where the word document makes any sense in an Ionic app. Why can’t you use the Platform resume event?

I found this example in another topic:

Anyway I changed to platform and it stills the same.

this.platform.resume.subscribe(e => {
this.saveUserAccess();
});

1 Like

I have the opposite problem. I want a resume event fired when coming back from call plugin. But on iOS it is not fired:

  public call(phoneNumber: string): void {
    const startDate: Date = new Date();
    if (this.platform.is("cordova")) {
      this.callNumber
        .callNumber(phoneNumber, true)
        .then(() => {
          console.log("create subscription");
          this.onResumeSubscription$ = this.platform.resume.subscribe(() => {
            console.log("subscriprion executed");
            this.openCallNoteAndSaveCall(startDate);
            this.onResumeSubscription$.unsubscribe();
          });
        })
        .catch(() => null);
    // } else if (this.platform.is("ios")) {
      // location.href = `tel:${phoneNumber}`;
    } else {
      location.href = `tel:${phoneNumber}`;
      this.openCallNoteAndSaveCall(startDate);
    }
  }

Any idea?

1 Like

I have the same issue, resume event is triggered every time the camera closes. Did you find a solution ?

1 Like

I have the same issue. But it creates a new subscription every time it returns from the camera. I want the subscription to be created once.