In-App Review in Android - MindOrks

文章推薦指數: 80 %
投票人數:10人

Upload your application in the internal test track and test it out. Upload your application in internal app sharing and test the review flow. CheckNowIn-AppReviewinAndroid So,youreleasedanappintheplaystoreandusersarelikingit.Butnowwewanttheuser'slikingtobeshownintheplaystoreviareviews.Butthefirstquestioniswhyweneedthereviews?Havinggoodreviewsinyourapplicationmakesalotofimpactonyourproductlikegoodrankingintheplaystoreanditalsohelpsanewusertotrustyourappmore.Buttodatewhatweusetodois,weusetoshowsomecustomtotakethemtoplaystoreandexpectuserswouldgivethereviewthere.Butithasfewissueslike,Theusermightchoosenottoaddanyreviewandjustleave.Theusermightdropfromtheappandthat'sabadpointastheuserisleavingtheapp.Wedon'twantouruserstoleavetheapplication.Tosolvetheseproblems,GooglelaunchedanIn-AppReviewAPI,asapartoftheplaycorelibrarywhichwecanusetoaddreviewsfromourapplicationitselfwithoutleavingtheapplicationandthatprovidesaverysmoothuserexperienceaswelltotheusers.Inthisblog,wearegoingtolearn,Whentoasktheusertoaddtheirreviewfortheapp.HowtointegratethenewIn-AppreviewAPI?HowtotesttheInAppReview?Whentoasktheusertoaddreviewtheapp.Consideringthattheuserhaslikedafeatureinyourapplicationorhascompletedsomelevelinyourgame,thatmightbeaplacetoshowtheReviewUItotheuser.Googlehasalsoprovidedsomeguidelinesforwherenottoaskforthereviewlike,WeshouldnotaddcustomUIalongsidetheReviewUIflow.Weshouldnotprompttheuserfrequentlyforareview,ithasquotaslimitassociatedwithit.Also,weshouldnothaveanycalltoactionlikeabuttontotriggertheIn-AppReviewAPI,theusersmighthittheirquotabytriggeringagainandagain.HowtointegratethenewIn-AppreviewAPI?Let'sstarttheintegrationoftheAPIinourapplication.Step01:AstheIn-AppReviewisapartofthePlaycorelibrary,weneedtoaddtherequireddependenciesinourapp'sbuild.gradlefilelike,implementation'com.google.android.play:core:1.8.2' implementation'com.google.android.play:core-ktx:1.8.1'Step02:Sincetheintegrationofdependenciesisdone,weneedtofigureoutthecorrectplacewhereweneedtoasktheuserforareview.Makesurethatyouaskatahappyplacewheretheuserhasachievedsomethinglike,Forexample,Ifyouareanappwhoisintherentalspacebusinessandhelppeoplegetroommatesfortheirvacantspacethenthebestplacetoaskreviewmightbewhenyouconnecttheuserwithapotentialroommate.Ifyouareagamingapp,thenmaybeshowthemaftercompletingalevelorsomethingsimilartoit.Theywouldhappilyrateyourapplicationandleaveagoodreviewastheyalreadyhadagoodexperienceforwhattheywerelookingfor.Step03:Now,sincewehavefiguredoutthebesttriggerpointtoaskforareview,letusstartintegratingtheReviewAPIitself.First,weneedtocreatetheinstanceofReviewManagerwhichwouldhelpustostarttheAPI.Wecreatetheinstanceusing,valmanager=ReviewManagerFactory.create(context)Now,usingthismanagerobjectwehavetorequesttheflowtolaunchtheIn-Appreviewflow.Wedoitlike,valrequest=manager.requestReviewFlow()Oncethisisdone,wecancheckiftherequestwassuccessfulinitsonCompleteListenerthenlet'sstartthein-appflowlike,request.addOnCompleteListener{request-> if(request.isSuccessful){ valreviewInfo=request.result }else{ //Handletheerrorhere } }AndwhenwegetthereviewInfoobject,wejuststartthereviewprocesslike,request.addOnCompleteListener{request-> if(request.isSuccessful){ valreviewInfo=request.result valflow=manager.launchReviewFlow(this,reviewInfo) flow.addOnCompleteListener{_-> //Continueyourapplicationprocess } }else{ //Handletheerrorhere } }InsidetheaddOnCompleteListener,wejustkeeptheapplication'sflowrunningirrespectiveofwhattheresultsare. ImageSource:developer.android.comNow,wearedonesettinguptheIn-AppReviewinourapplication.HowtotesttheIn-AppReview?Now,sincewehaveintegratedtheflow,weneedtotestitoutandmakesureitworksfineforus.Todoit,wehaveacoupleofwaystotestitoutlike,Uploadyourapplicationintheinternaltesttrackandtestitout.Uploadyourapplicationininternalappsharingandtestthereviewflow.Now,whiletestingitintestcasestocheckifthereviewflowiscompletedandtheapp'sflowisexecutingintheexpectedflowthenweusedFakeReviewManagerinplaceofReviewManagerFactorylike,valmanager=FakeReviewManager(this)ThiswouldnottriggertheUIbutonlytakecareoffakingtheresultbygivingusthefakeReviewInfoobject.PointtotakecareofwhileusingIn-AppReviewAPIYouwillseetheReviewUIonlyifyourprimaryaccounthasnotalreadyreviewedtheapp.HappyLearning:)HimanshuSinghShowyourlovebysharingthisblogwithyourfellowdevelopers.ShareonFacebookShareonTwitterShareonRedditShareonLinkedInShareonTelegramShareonWhatsapp



請為這篇文章評分?