parse points url with product id and navigate to purchase

This commit is contained in:
Sadaqat Ali 2022-08-13 15:20:21 +05:00
parent 9670e829dd
commit c5c1ad2ee6
3 changed files with 16 additions and 4 deletions

View File

@ -59,7 +59,7 @@ class InAppPurchaseContainer extends Component {
await this._consumeAvailablePurchases()
this._getItems();
this._purchaseUpdatedListener();
await this._handleQrPurchase();
} catch (err) {
bugsnagInstance.notify(err);
console.warn(err.code, err.message);
@ -202,6 +202,15 @@ class InAppPurchaseContainer extends Component {
}
};
_handleQrPurchase = async () => {
const { navigation, skus } = this.props as any;
const products = await RNIap.getProducts(skus);
const productId = navigation.getParam('productId', '');
if(productId && products && products.find((product) => product.productId === productId)){
await this._buyItem(productId);
}
}
render() {
const { children, isNoSpin } = this.props;
const { productList, isLoading, isProcessing } = this.state;

View File

@ -83,8 +83,8 @@ export const deepLinkParser = async (url, currentAccount) => {
}
//if url is for purchase
const { type, username} = parsePurchaseUrl(url) || {};
console.log('type, username : ', type, username);
const { type, username, productId} = parsePurchaseUrl(url) || {};
// console.log('type, username, productId : ', type, username, productId);
if(type && type === 'boost'){
routeName = ROUTES.SCREENS.ACCOUNT_BOOST;
params = {
@ -96,6 +96,7 @@ export const deepLinkParser = async (url, currentAccount) => {
routeName = ROUTES.SCREENS.BOOST;
params = {
username,
productId
};
keey = `${type}/${username || ''}`;
}

View File

@ -10,9 +10,11 @@ export default (urlString:string) => {
if(url.pathname === '/purchase'){
const type = url.searchParams.get('type');
const username = url.searchParams.get('username');
const productId = url.searchParams.get('product_id');
return {
type,
username
username,
productId
}
}