Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Android native in app review + revised native reviews flow #281

Merged
merged 8 commits into from
Sep 8, 2020

Conversation

regevbr
Copy link
Contributor

@regevbr regevbr commented Sep 5, 2020

fix: #276

This PR adds the native Android in-app review feature.

Since both Apple and Android in-app reviews explicitly dictate not to prompt the user before calling the review API (as it might not be shown at all) I have revised the logic so if someone wants in-app review (in Android and/or IOS) and the native prompt is supported, no custom prompt will be shown (breaking change)

Backward compatibility was also in mind. Also, it will be bulletproof to CodePush updates that will update the js file of the plugin without updating the native code.
@westonganger I would appreciate your review and thoughts.

Please note that the Android in-app review is very hard to debug/display as I mentioned in the readme and can only be done in test track releases. I managed to get the native prompt logic to work on the test track version of my app with this PR but Android refuses to actually show me the dialog (all the callbacks states success results). Since this is a really new feature, there is not much info on the web to help debug it. So I would appreciate if someone can test it out and see if it works for them @terreng @rodrigograca31
I confirmed the PR works perfectly in Android

WhatsApp Image 2020-09-05 at 21 45 44

README.md Outdated Show resolved Hide resolved
www/AppRate.js Outdated Show resolved Hide resolved
@regevbr
Copy link
Contributor Author

regevbr commented Sep 5, 2020

@westonganger you can actually help in verifying the PR, is you can share with me your gmail account, I can add you as a beta tester of my app and you should probably see the review popup as I'm guessing you never rated our app before, and I suspect that is the reason I can't test it (Even though I deleted my review like Google suggested)

@westonganger
Copy link
Collaborator

Sorry I do not own an Android device currently.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 5, 2020

No worries I'll get a hold of an old android device tommrow to test it out

@regevbr
Copy link
Contributor Author

regevbr commented Sep 5, 2020

I confirmed the PR works! see screenshot in the edited PR description

@rodrigograca31
Copy link
Contributor

Thanks a lot for this!

I'm still confused how/when does the native prompt show?
I didn't understand if there was a specific way to call it or if the code auto decides and doesn't show the normal questions just calls the native prompt directly...?

Also not sure if this wont conflict with other plugins:

<preference name="PLAY_CORE_VERSION" default="1.8.0"/>
        <framework src="com.google.android.play:core:$PLAY_CORE_VERSION" />

probably not but just asking... does it support the typical semver ^ ? maybe we should use it?

Thanks for your time!

@regevbr
Copy link
Contributor Author

regevbr commented Sep 6, 2020

@rodrigograca31 sure thing

I'm still confused how/when does the native prompt show?
I didn't understand if there was a specific way to call it or if the code auto decides and doesn't show the normal questions just calls the native prompt directly...?

In both Android and iOS you can use native code to call the native review prompt whenever you want, but you never know if it actually was shown or not to the user and whether or not the user reviewed. Because of that behavior, they say you are not allowed to prompt the user yourself before initiating the native prompt because it might not appear and thus causes confusion to the user. As such, this PR will skip the custom prompt you are used to and initiate the native prompt immediately. This scenario can only happen if the configuration states the "InAppReview" review type and the native review API is available. Otherwise it will fall back to the current behavior.

probably not but just asking... does it support the typical semver ^ ? maybe we should use it?

Sure I will switch it up to semver

@westonganger
Copy link
Collaborator

westonganger commented Sep 6, 2020

Are you adding a new public method isNativePromptAvailable? This needs to be documented.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 6, 2020

@westonganger this is actually the name of a private non-accessible method, and also the name of a preference that is not controlled by the user, and as such should not be documented

@westonganger
Copy link
Collaborator

Ok then please do not use AppRate.preferences to hold the variable AppRate.preferences.isNativePromptAvailable

@westonganger
Copy link
Collaborator

Also please be sure to document how it will fallback to InAppBrowser when the native prompt is not available.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 6, 2020

I followed ths same logic just like the app title is handled in the init function but sure I will change it.
About the documentation - will add it now

@regevbr
Copy link
Contributor Author

regevbr commented Sep 6, 2020

@westonganger I tried to explain it as much as I can but my verbal skills were never a strong suit of mine :-) Please let me know how I can improve it.

@maandagdev
Copy link

Hey, when will this be merged? If there is anything I can help with to get it merged quicker please let me know.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 8, 2020

@westonganger is there anything else I need to change in order to get this update rolling?

@westonganger westonganger merged commit 91d3695 into pushandplay:master Sep 8, 2020
@westonganger
Copy link
Collaborator

Merged. Thanks for your hard work on this.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 8, 2020

Sure thing @westonganger and thanks for the CR!
Can we expect a new version soon, or should I just install the library using commit hash?

@westonganger
Copy link
Collaborator

Yes just install via commit hash, again, I like to give time before releasing new versions.

@maandagdev
Copy link

@regevbr I just tried using this PR and when I set InAppReview to true it no longer works in IOS, am I doing something wrong?

I am quite sure I am using the correct commit hash as well;
"cordova-plugin-apprate": "git+https://github.com/pushandplay/cordova-plugin-apprate.git#91d3695",

@regevbr
Copy link
Contributor Author

regevbr commented Sep 9, 2020

@maandagdev the commit hash is ok
Please notice that the configurations were changed and the inAppReview preference was deprecated What you need to configure is:

  reviewType: {
    ios: 'InAppReview',
    android: 'InAppReview'
  },

Also notice that as mentioned in the docs, the prompt won't always be shown and you can't be aware if it did or not.
If you try to launch a review in IOS and your user already provided a review in the past, it will not be shown again. Also, iOS has a max 3 times a year review prompt quota.
In addition, when using the in app review, the custom prompt you are used to is not being shown as well.
Also, don't forget that this plugin maintains a state of the number of times a review was requested, so maybe it didn't even initiate the review request, based on your configuration...
If you still think that there is a bug here, please open a new issue (don't forget to tag me) and give more details (like your full configuration and test environment)

@maandagdev
Copy link

@regevbr I am getting the following error though;

Object literal may only specify known properties, and 'reviewType' does not exist in type 'AppRatePreferences'.

@regevbr
Copy link
Contributor Author

regevbr commented Sep 11, 2020

@maandagdev it seems you are not using the updated code. The update was not officially released yet and in order to get that feature you will need to install by commit hash git+https://github.com/pushandplay/cordova-plugin-apprate.git#91d3695

@regevbr
Copy link
Contributor Author

regevbr commented Sep 11, 2020

@maandagdev in Cordova to update a plugin you must remove it then reinstall it (fucked up I know)
Also make sure your lock file gets updated as well

@rodrigograca31
Copy link
Contributor

Worked perfectly! Thanks @regevbr

Just had to:

ionic cordova plugin rm cordova-plugin-apprate
ionic cordova plugin add git+https://github.com/pushandplay/cordova-plugin-apprate.git#91d3695

and add this line to my code: AppRate.preferences.reviewType.android = "InAppReview";

@maandagdev
Copy link

@regevbr Thank you, I had the ionic native package installed thats why I did not see the new style. But I can't for the life of me get it to work. I put this in my .ts file:
import {AppRate} from 'cordova-plugin-apprate';

But when I copy and paste the example it gives me errors and I need to fill in all options. Do you have any idea why? What am I doing wrong here?

@regevbr
Copy link
Contributor Author

regevbr commented Sep 16, 2020

@maandagdev sadly not, I never worked with Ionic, or used typescript in my cordova projects. Can you please share some screenshots and detailed errors? When you go to the definition of app rate do you see the latest code?

@maandagdev
Copy link

@regevbr I have it working, when I debug through the code it all looks okay and everything looks fine. the task.success even returns true. But I see nothing in the app, any idea why?

@regevbr
Copy link
Contributor Author

regevbr commented Sep 17, 2020

@maandagdev as mentioned in the readme, there is no way to force it to show when using native... and there is no way to know if it was actually opened or not... if you are using IOS, you will always see it in the simulator and testing phase. If you are using Android, you will always see it in the test track (given that you never reviewed the app before)

@maandagdev
Copy link

@maandagdev as mentioned in the readme, there is no way to force it to show when using native... and there is no way to know if it was actually opened or not... if you are using IOS, you will always see it in the simulator and testing phase. If you are using Android, you will always see it in the test track (given that you never reviewed the app before)

Ah yeah, I just read it.. my bad, I am an idiot.

I have an app in review currently so I can't really talk on Android, I will give it a shot when I can do a release in a bit. Thanks for your help though, I did get it working 👍

@rodrigograca31
Copy link
Contributor

and make sure you are a tester.....

@fishgrind
Copy link

@regevbr Thank you, I had the ionic native package installed thats why I did not see the new style. But I can't for the life of me get it to work. I put this in my .ts file:
import {AppRate} from 'cordova-plugin-apprate';

if you are going to use it without the ionic wrapper you don't need the import, that won't work.

use: declare var AppRate: any;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for in-app reviews on Android
5 participants