Kebechet / Maui.RevenueCat.InAppBilling

MIT License
13 stars 6 forks source link

Implement check if GooglePlay/Apple store is activated (installed & user signed in) #35

Open Kebechet opened 9 months ago

Kebechet commented 9 months ago

Source: Android , iOS

Test with Android emulator where you log out from the store

Example:

            catch ( Xamarin.RevenueCat.Android.Extensions.Exceptions.PurchasesErrorException ex )
            {
                string description = ex.PurchasesError.Code.Description;
                string diagnosis = ex.PurchasesError.UnderlyingErrorMessage;        // Debug - real reason for the problem
                RevenueCatXamarin.Droid.Utilities.Show_Dialog msg = new Utilities.Show_Dialog ();
                if ( description.Contains ( "problem with the store" ) )
                {
                    description = S.StoreProblemInDetail;       // Ask user to verify logged in to Google and re-start app
                    await msg.ShowDialogAsync ( S.Warning, description );

                    // Continuing is possible in some circumstances
                    return;
                }
                else if ( ex.PurchasesError.Code == PurchasesErrorCode.PurchaseNotAllowedError )
                {
                    // Results from Google Play status BILLING_UNAVAILABLE
                    // Likely causes:
                    //      The Play Store app on the user's device is out of date
                    //      Google Play is unable to charge the user's payment method
                    //      The user is an enterprise user and their enterprise admin has disabled users from making purchases
                    //      The user is in a country not supported by Google
                    // Advise user then allow user to continue

                    string message = S.BillingUnavailable1 + Environment.NewLine  + Environment.NewLine +
                     S.BillingUnavailable2 + Environment.NewLine  + Environment.NewLine +
                     S.BillingUnavailable3 + Environment.NewLine  +
                     S.BillingUnavailable4 + Environment.NewLine  +
                     S.BillingUnavailable5 + Environment.NewLine  +
                     S.BillingUnavailable6 + Environment.NewLine + Environment.NewLine +
                     S.BillingUnavailable7;

                    await msg.ShowDialogAsync ( S.Warning, message );
                    return;
                }
[[Purchases] - ERROR] 🤖‼️ Error when fetching products DebugMessage: An internal error occurred.. ErrorCode: SERVICE_UNAVAILABLE.
[[Purchases] - ERROR] 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when fetching products. DebugMessage: An internal error occurred.. ErrorCode: SERVICE_UNAVAILABLE., message='There was a problem with the store.')
[[Purchases] - ERROR] 🤖‼️ Error fetching offerings - PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when fetching products. DebugMessage: An internal error occurred.. ErrorCode: SERVICE_UNAVAILABLE., message='There was a problem with the store.')