diff --git a/.env b/.env index 1959d91..0692943 100644 --- a/.env +++ b/.env @@ -4,3 +4,5 @@ VUE_APP_UNSAFE_STATUSBAR_COLOR=#FF5C5D VUE_APP_SAFE_STATUSBAR_COLOR=#47BD8F VUE_APP_STORE_REVIEWS_ENABLED=true VUE_APP_IOS_APP_ID = 'id1434675665' +VUE_APP_SUPPORT_EMAIL = 'beep@moduscreate.com' +VUE_APP_SUPPORT_EMAIL_SUBJECT = 'Feedback: About beep' diff --git a/src/components/ReviewAppModal.vue b/src/components/ReviewAppModal.vue new file mode 100644 index 0000000..51fa5c5 --- /dev/null +++ b/src/components/ReviewAppModal.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/mixins/hasModal.js b/src/mixins/hasModal.js index 26aac81..ce92315 100644 --- a/src/mixins/hasModal.js +++ b/src/mixins/hasModal.js @@ -14,9 +14,11 @@ export default { methods: { toggleModal(modalComponent = null) { if (!this.isModalOpen) { - this.openModal(modalComponent) + this.isModalOpen = !this.isModalOpen + return this.openModal(modalComponent) } this.isModalOpen = !this.isModalOpen + return Promise.resolve() }, async openModal(modalComponent = null) { const modal = await this.$ionic.modalController.create({ diff --git a/src/mixins/reviewAppModal.js b/src/mixins/reviewAppModal.js new file mode 100644 index 0000000..5d5dfea --- /dev/null +++ b/src/mixins/reviewAppModal.js @@ -0,0 +1,17 @@ +import reviewAppModal from '@/components/ReviewAppModal.vue' + +export default { + data() { + return { + reviewAppModal, + } + }, + methods: { + async tryPromptAppReview() { + if (this.$reviewAppService.shouldPromptAppReview()) { + await this.toggleModal(this.reviewAppModal) + this.$reviewAppService.storeReviewRejected = true + } + }, + }, +} diff --git a/src/reviewAppService.js b/src/reviewAppService.js index 2d476c6..81de82e 100644 --- a/src/reviewAppService.js +++ b/src/reviewAppService.js @@ -1,7 +1,7 @@ import capacitorConfig from '../capacitor.config.json' import { Capacitor, Plugins, Device } from '@capacitor/core' import helpers from './helpers' -const { Modals, Browser, Storage } = Plugins +const { Browser, Storage } = Plugins const { cordova } = window const iOSAppId = helpers.iOSAppId() @@ -9,6 +9,8 @@ const DEV_ITUNES_URL = `https://itunes.apple.com/us/app/apple-store/${iOSAppId}` const STORE_URL_FORMAT_IOS8 = `https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8&id=${iOSAppId}` const STORE_URL_PREFIX_IOS9 = `https://itunes.apple.com/app/viewContentsUserReviews/${iOSAppId}?action=write-review` const storeReviewDoneStorageKey = 'storeReviewDone' +const supportEmail = helpers.env('SUPPORT_EMAIL') +const supportEmailSubject = helpers.env('SUPPORT_EMAIL_SUBJECT') export default { storeReviewsEnabled: helpers.storeReviewsEnabled(), @@ -46,40 +48,19 @@ export default { registerCheck() { this.revisionsDone++ }, - tryPromptAppReview(forceReview = false) { + shouldPromptAppReview() { // We only prompt for an app review if: // a. The feature is enabled // b. We are on a non web environment // c. The user has executed only one account/password review // d. The user has not accepted or rejected to provied a review for the app on the app stores yet - // OR - // a. The feature is enabled - // b. The review request is forced (like when is triggered manually by the user, from a global menu for instance) - if ( + return ( this.storeReviewsEnabled && !helpers.isWeb() && - ((this.revisionsDone === 1 && !this.storeReviewDone && !this.storeReviewRejected) || - forceReview) - ) { - this.doPromptAppReview() - } - }, - doPromptAppReview() { - Modals.confirm({ - title: 'Have some feedback?', - message: 'Do you want to review this app?', - okButtonTitle: 'Sure', - cancelButtonTitle: 'Not now', - }) - .then(({ value }) => { - if (value) { - this.suggestAppReview() - } else { - this.storeReviewRejected = true - } - return - }) - .catch(helpers.err) + this.revisionsDone === 1 && + !this.storeReviewDone && + !this.storeReviewRejected + ) }, async suggestAppReview() { const url = this.getStoreHint() @@ -90,6 +71,7 @@ export default { cordova.plugins.market.open(url) this.setReviewDone() } + return Promise.resolve() }, async setReviewDone() { await Storage.set({ @@ -98,4 +80,8 @@ export default { }) this.storeReviewDone = true }, + async provideAppFeedback() { + await this.setReviewDone() + window.location.href = `mailto:${supportEmail}?subject=${supportEmailSubject}` + } } diff --git a/src/views/Acc.vue b/src/views/Acc.vue index 6c27af8..4516e44 100644 --- a/src/views/Acc.vue +++ b/src/views/Acc.vue @@ -46,10 +46,12 @@