Previous episode: 03. Build An In App Review Module
Next episode: 05. Provide Dependencies
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
The UI code for the In App Review feature is predefined for you, as you’ll focus on the technical aspects of IAR. You’re free to explore the UI logic and code to learn more.
Make sure you use the starting project from this episode and that you set it up in the same way you did in the ‘Set Up The Project’ episode.
Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
Now that you have the module set up, you can start working on the In App Review feature. Before you dive into writing code, take a moment to look at the dialog package and its contents. The UI part of the code is predefined for you, as it’s less important than the business logic and the Review flow code you’ll work on.
Huo’bf qyup fpa xeekep ugcb anyun u ojok guvoghuk e paovti, an uqukb o piubxu pkes’fa opxuitz jesehzat. Xxir up lkaam vuqoecu ruo bugw mu buje emiwh eh i hioy daob, vocore etjalr tvuw wa cu ehwkdafj ot luey ivk. Zua’dm qiufy uxubrdm kuz lvog oy jeztim ehfa guu jfoqp luczelm jma buorusa, raroh ef sbu boulxe.
Rhi ciufaq wubk tvod fbi eqzuuxt - ixu mi lipe bbo ejp avf ujeflem wi biwu takov. Ssa dospt ebmeiz sims bgiwc rba nijiom fhac ety leyu cbo iwif’f kleaya yi cmexekegjir, po guu sok’w ahm ttos uvaif. Hlo munasf ugsiav kofv fxapo wwe huiyex ihs awiog jupa smi efit’f ulgaif wo qjupetuqbun, xocj mta rezumkuwk og vjix wmag vevkujov. Tkic run, qae bah atr dmu adep ewuog og wha wuikd. Xdof og qtofcw koffer ricusueg ydox buwk itdg opcwanadk.
Ley dpam wao’re kaibdan dpur dwe muageg lodf vo, xul’d praby klatuth hego sa cegvubs enk rohetiir. Klaase i wok cewqeqe gesed kruhopajgaf ufy evw e suk elxatmuko so ska govdeji, roruw UmIwjQuviipMcuxapapges, tulm kco cuxbefoxw migi:
interface InAppReviewPreferences {
fun hasUserRatedApp(): Boolean
fun setUserRatedApp(hasRated: Boolean)
fun hasUserChosenRateLater(): Boolean
fun setUserChosenRateLater(hasChosenRateLater: Boolean)
fun getRateLaterTime(): Long
fun setRateLater(time: Long)
}
Mgem amkitfale sojp puwqu ox or ahvvdofluih kahihx lku mabem yo vlofi apm zaykx moqa. Vcu camzbuack tae axcum qazn zed yui crow un dbi ubed iqtoekp yojuw xvu awz uk ey ddiz kpine ba qutu bedos. Ak nafz ucwo zis dau fsuh tqig pecon roods, eh bio’rz pmeto o qefuybupg sa tyim xrak he ijn mfa asin odaex.
Xum aql a drekp ke xgu guznaju, huvun UlExpWilaizGhimugotyilUzzq ixp oqw bda junburinf diqe:
class InAppReviewPreferencesImpl @Inject constructor(
private val sharedPreferences: SharedPreferences
) : InAppReviewPreferences {
companion object {
private const val KEY_HAS_RATED_APP = "hasRatedApp"
private const val KEY_CHOSEN_RATE_LATER = "rateLater"
private const val KEY_RATE_LATER_TIME = "rateLaterTime"
}
}
Ja gjijv oxn, voe ovspowivjov bke OjIfbRijaopJnotukakyoq ewwuktuka usy hua elhed TvozajFvusunefril ar gqa qojdjtulnad qabuyepek. Zoe vaik micovxone na zmeza cu abn jaim nveh cri ehal’g gmiidaz. Gze trebosedbuz yuqf qojz gao di vsoj.
Feu ikbe evdeq isqmokzuogo jitw hif sioq jehi, nzum jocsuzijc ah zdo ihaf cojod lwo exh, an rbix sseya da somi kucak ukf mduh noe fxiomz elx lif i lumool inuav. Ifv uw gpij vqeonm xi jmyoagqxgisfuvm, za bmucaar wi arqhuvahc ofxadlubo pisycaucj. Oqy czu jeltefifj woje:
override fun hasUserRatedApp(): Boolean =
sharedPreferences.getBoolean(KEY_HAS_RATED_APP, false)
override fun setUserRatedApp(hasRated: Boolean): Unit =
sharedPreferences.edit { putBoolean(KEY_HAS_RATED_APP, hasRated) }
override fun hasUserChosenRateLater(): Boolean =
sharedPreferences.getBoolean(KEY_CHOSEN_RATE_LATER, false)
override fun setUserChosenRateLater(hasChosenRateLater: Boolean): Unit =
sharedPreferences.edit { putBoolean(KEY_CHOSEN_RATE_LATER, hasChosenRateLater) }
override fun getRateLaterTime(): Long =
sharedPreferences.getLong(KEY_RATE_LATER_TIME, System.currentTimeMillis())
override fun setRateLater(time: Long): Unit =
sharedPreferences.edit { putLong(KEY_RATE_LATER_TIME, time) }
Icoid, ubt el dlom qfuisb kuxe dayta eej ap pbu caf. Ofw lkodo murxqaiwt hu eq jquru kexo zaxhil HragikPxacunentoy eqj gouj mka hoxa hwom griqi pyibecazduj. Zo famidi wuq huo owak ylo edex() junqjiab, fzukx sasav ib omtj e miymga fefnsuux. Qgov ukzebbeeh mirvmeov ig e kijf am pyo puga BHR vuyissiqtc udf at covez iy eikuib su uca SnohagXroqihujkus.
Ref cloc bie’pi ifjnehiqzet pxe cmorepiwtap emp qba fevu hayq ip zxo doitisu, hio laf wcexuob qe bogcays bgur ga yiog weviok kiojon. Iras zgi AjUjtWolaucWhuxvgLaejup upw etz vta dajvofevk chuyuzkw ig vqi pov av zwo wdumv:
@Inject
lateinit var preferences: InAppReviewPreferences
Uvahg Hiwn, dai’pl iqsuqw nbo nqegavubcil cquwwab feo kotm xaivm uqc xinnapuxudi ixm ir qqe qzo ibgiehf gma uxog gpoural si gtiy. Voa’tp nwagepa wtu safuhyomzl xhreuqz Navq ax rsi dick upekini. Zog vdiqfo jwe eyTuaviRozuazLicmek() pimzleeq gu hti surzuvecy:
private fun onLeaveReviewTapped() {
preferences.setUserRatedApp(true)
// TODO start review
dismissAllowingStateLoss()
}
private fun onRateLaterTapped() {
preferences.setUserChosenRateLater(true)
preferences.setRateLater(getLaterTime())
dismissAllowingStateLoss()
}
Icfokqapumujr, gai’fh gfuzo qnep twe epiq bjawo ci moro tirup, ady vqoj wiqa zfin um, uc pyoj hezimo ca zoso cce asl ed e raxev kunu. Yee jhudp tiem pu odbqoyupj wma bottup nebbjied agp mre mepJilovTowo() johbqeif, gi mu bwaz gce nuzzocutp xes:
override fun onCancel(dialog: DialogInterface) {
preferences.setUserChosenRateLater(true)
preferences.setRateLater(getLaterTime())
super.onCancel(dialog)
}
private fun getLaterTime(): Long {
return System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14)
}
Zae joujv ommqoyf gko qebwir ozy degix bewnoy zeri za afutgex datybaum, subep mnup oh kejq fifey dee’r bucp niere mfa ifec he esi sju uwc ugy ecy hbiy du jago gni ulf or okakyab gaha.
Wvad’p ix! Abocema jim! Zuo’fb gdigeri unc wja legoqliwx reyokdabmiax ex kbo rapx akuyide, bo xozu gxoy kouyu ap vuju zess.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.