jamesmontemagno / StoreReviewPlugin

Request app store reviews across Xamarin and Windows applications
MIT License
184 stars 24 forks source link

App crashes plugin OnNavigatedTo #43

Closed mdmota closed 1 year ago

mdmota commented 1 year ago

All settings are correct regarding obfuscator and link. My app opens a pdf in another app, when the user closes the pdf, the async OnNavigatedTo is called, when executing the plugin call it throws an exception and the app closes. Important detail, when I reopen the app and go to that same screen, the plugin opens correctly:

   public async override void OnNavigatedTo(INavigationParameters parameters)
        {
            if (CrossStoreReview.IsSupported)
            {
                await CrossStoreReview.Current.RequestReview(false);
            }
        }

Fatal Exception: android.runtiAe.JavaProxyThrowable: System.Threading.Tasks.TaskCanceledException: The task was cancelled. at Plugin.StoreReview.StoreReviewImplementation.RequestReview (System.Boolean testMode) [0x000d6] in :0 at myPackage.ViewModel.OnNavigatedTo (Prism.Navigation.INavigationParameters parameters) [0x000fb] in <8d0e734f47914b3f9d4fe75c0124ee91>:0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b7_0 (System.Object state) [0x00000] in <0337a65526184dd6ab17a0cf1d8c69a6>:0 at Android.App.SyncContext+<>c__DisplayClass2_0.b0() [0x00000] in <0c70aef4056a47d49fa85b6963e11f45>:0 at Java.Lang.Thread+RunnableImplementor.Run() [0x00008] in <0c70aef4056a47d49fa85b6963e11f45>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <0c70aef4056a47d49fa85b6963e11f45>:0 at (dynamic-method wrapper) Android.Runtime.DynamicMethodNameCounter.43(intptr,intptr) at mono.java.lang.RunnableImplementor.n_run() at mono.java.lang.RunnableImplementor.run() at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.app.ActivityThread.main(ActivityThread.java:8051) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

@jamesmontemagno Any idea?

jamesmontemagno commented 1 year ago

Can you put it OnAppearing?

mdmota commented 1 year ago

I use prism and my contentPage doesn't implement the method OnAppearing. Actually my OnNavigatedTo calls an async method before call plugin:

  public async override void OnNavigatedTo(INavigationParameters parameters)
         {
             await MyMethdodAsync();
              if (CrossStoreReview.IsSupported)
            {
                await CrossStoreReview.Current.RequestReview(false);
            }
         }
saamerm commented 1 year ago

@mdmota are you able to add the project manually and then debug through the issue? And is this happening with Android MAUI?

mdmota commented 1 year ago

I'm going to close the issue, we actually changed the plugin's call sequence and it ended up solving. It was conflicting with that share window that is in the same area. Calling the plugin before the share window worked.