Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

load products on app start

ammarahm-ed135555774237
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index bdc05c6fb..0c7d6ffdc 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -9,8 +9,11 @@ import {
} from '../utils/Events';
import {MMKV} from '../utils/mmkv';
import {eSendEvent, ToastEvent} from './EventManager';
+import * as RNIap from 'react-native-iap';
+import {itemSkus} from '../utils';
let premiumStatus = 0;
+let products = [];
async function setPremiumStatus() {
try {
@@ -18,16 +21,26 @@ async function setPremiumStatus() {
if (!user) {
premiumStatus = null;
updateEvent({type: Actions.PREMIUM, state: get()});
+
+
} else {
premiumStatus = user.subscription.type;
updateEvent({type: Actions.PREMIUM, state: get()});
updateEvent({type: Actions.USER, user: user});
+ if (!get()) {
+ await RNIap.initConnection();
+ products = await RNIap.getSubscriptions(itemSkus);
+ }
}
} catch (e) {
premiumStatus = null;
}
}
+function getProducts() {
+ return products;
+}
+
function get() {
return (
premiumStatus === 1 ||
@@ -159,4 +172,5 @@ export default {
get,
onUserStatusCheck,
showVerifyEmailDialog,
+ getProducts
};