NativeScript / nativescript-app-sync

♻️ Update your app without going through the app store!
MIT License
125 stars 24 forks source link

How do I know AppSync.sync is finished? #48

Closed alonstar closed 4 years ago

alonstar commented 4 years ago

I want to display dialog when sync is finished, but when I added show modal function (Nativesciprt +Angular) in SuccessCallback using ModalDialogService, ios is not working.

I tried to set timeout for showing dialog (I tried 300, 500, 1000, even 3000), but it's not work. And I moved show modal out SuccessCallback it's ok.

But I can't try add it after App.Sync...because it's a void.

How could I do for this issue?

EddyVerbruggen commented 4 years ago

Look for syncStatus here.

And to show a dialog you may need to wrap that logic in an ngZone (Google it if it doesn't ring a bell).

alonstar commented 4 years ago

hi, ~ Thanks for your help. My original code is: (this.installed is a function shows modal)

      case SyncStatus.UPDATE_INSTALLED:
              this.installed()
        break;

It's work in android, but not ios. And I have already tried using ngZone.run like:

      setTimeout(() => this.zone.run(() => this.installed()), 3000);

OR

      this.zone.run(() => setTimeout(() => this.installed(), 3000));

OR

      this.zone.run(AppSync.sync());

All are not work. T_T

EddyVerbruggen commented 4 years ago

If you console.log it, does it show up in the log?

alonstar commented 4 years ago

Yes. Log is work, and I tried "confirm" it is work, too. I don't know why modal service is not work. T_T

And there is no any error.

EddyVerbruggen commented 4 years ago

No idea either, but if the log works then I guess at least the plugin works correctly.

alonstar commented 4 years ago

Oh, If I run on debug mode and set breakpoint on SuccessCallback, then run it step by step , it is work.

Amazing!