feat: mobile app package (#1075)

This commit is contained in:
Mo
2022-06-09 09:45:15 -05:00
committed by GitHub
parent 58b63898de
commit 8248a38280
336 changed files with 47696 additions and 22563 deletions

View File

@@ -0,0 +1,25 @@
import { ApplicationService, Platform } from '@standardnotes/snjs'
import * as StoreReview from 'react-native-store-review'
const RUN_COUNTS_BEFORE_REVIEW = [18, 45, 105]
export class ReviewService extends ApplicationService {
override async onAppLaunch() {
if (this.application?.platform === Platform.Android || !StoreReview.isAvailable) {
return
}
const runCount = await this.getRunCount()
void this.setRunCount(runCount + 1)
if (RUN_COUNTS_BEFORE_REVIEW.includes(runCount)) {
setTimeout(function () {
StoreReview.requestReview()
}, 1000)
}
}
async getRunCount() {
return Number(this.application?.getValue('runCount'))
}
async setRunCount(runCount: number) {
return this.application?.setValue('runCount', runCount)
}
}