diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 33fc14ec9..d3e12dd11 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -92,6 +92,11 @@ android:host="ecency.com" android:path="/signup" /> + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9161cfe47..754f09c9e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -827,4 +827,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 0282022703ad578ab2d9afbf3147ba3b373b4311 -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/src/components/postBoost/postBoostView.js b/src/components/postBoost/postBoostView.js index 605cd162b..183b651ec 100644 --- a/src/components/postBoost/postBoostView.js +++ b/src/components/postBoost/postBoostView.js @@ -21,7 +21,6 @@ import { Modal } from '../modal'; // Styles import styles from './postBoostStyles'; import { OptionsModal } from '../atoms'; -import { deepLinkParser } from '../../utils/deepLinkParser'; import postUrlParser from '../../utils/postUrlParser'; class BoostPostScreen extends PureComponent { diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 82271b924..19e6a7a2f 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -585,7 +585,8 @@ }, "deep_link": { "no_existing_user": "No existing user", - "no_existing_post": "No existing post" + "no_existing_post": "No existing post", + "invalid_link":"Url is invalid, you may try again with valid url or try opening it in web browser" }, "search": { "posts": "Posts", diff --git a/src/containers/inAppPurchaseContainer.ts b/src/containers/inAppPurchaseContainer.ts index 3367e61b0..62f7d288a 100644 --- a/src/containers/inAppPurchaseContainer.ts +++ b/src/containers/inAppPurchaseContainer.ts @@ -28,21 +28,8 @@ class InAppPurchaseContainer extends Component { } // Component Life Cycle Functions - async componentDidMount() { - try { - await RNIap.initConnection(); - if (Platform.OS === 'android') { - await RNIap.flushFailedPurchasesCachedAsPendingAndroid(); - } - - this._consumeAvailablePurchases() - - } catch (err) { - bugsnagInstance.notify(err); - console.warn(err.code, err.message); - } - this._getItems(); - this._purchaseUpdatedListener(); + componentDidMount() { + this._initContainer(); } componentWillUnmount() { @@ -59,6 +46,35 @@ class InAppPurchaseContainer extends Component { } + _initContainer = async () => { + const { + intl, + } = this.props; + try { + await RNIap.initConnection(); + if (Platform.OS === 'android') { + await RNIap.flushFailedPurchasesCachedAsPendingAndroid(); + } + + await this._consumeAvailablePurchases() + this._getItems(); + this._purchaseUpdatedListener(); + + } catch (err) { + bugsnagInstance.notify(err); + console.warn(err.code, err.message); + + Alert.alert( + intl.formatMessage({ + id: 'alert.connection_issues', + }), + err.message + ); + } + + } + + //this snippet consumes all previously bought purchases //that are set to be consumed yet _consumeAvailablePurchases = async () => { @@ -152,7 +168,7 @@ class InAppPurchaseContainer extends Component { const products = await RNIap.getProducts(skus); console.log(products); products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse(); - await this.setState({ productList: products }); + this.setState({ productList: products }); } catch (err) { bugsnagInstance.notify(err); Alert.alert( @@ -163,7 +179,7 @@ class InAppPurchaseContainer extends Component { ); } - await this.setState({ isLoading: false }); + this.setState({ isLoading: false }); }; _buyItem = async (sku) => { diff --git a/src/screens/application/container/applicationContainer.tsx b/src/screens/application/container/applicationContainer.tsx index acba6198d..f780e3548 100644 --- a/src/screens/application/container/applicationContainer.tsx +++ b/src/screens/application/container/applicationContainer.tsx @@ -91,6 +91,7 @@ import parseAuthUrl from '../../../utils/parseAuthUrl'; import { purgeExpiredCache } from '../../../redux/actions/cacheActions'; import { fetchSubscribedCommunities } from '../../../redux/actions/communitiesAction'; import MigrationHelpers from '../../../utils/migrationHelpers'; +import { deepLinkParser } from '../../../utils/deepLinkParser'; // Workaround let previousAppState = 'background'; @@ -236,93 +237,25 @@ class ApplicationContainer extends Component { }; _handleDeepLink = async (url = '') => { - if (!url || url.indexOf('ShareMedia://') >= 0) return; + const { currentAccount, intl } = this.props; - let routeName; - let params; - let content; - let profile; - let keey; - const { currentAccount } = this.props; - - const postUrl = postUrlParser(url); - const { author, permlink, feedType, tag } = postUrl || {}; - - try { - if (author) { - if ( - !permlink || - permlink === 'wallet' || - permlink === 'points' || - permlink === 'comments' || - permlink === 'replies' || - permlink === 'posts' - ) { - let deepLinkFilter; - if (permlink) { - deepLinkFilter = permlink === 'points' ? 'wallet' : permlink; - } - - profile = await getUser(author); - routeName = ROUTES.SCREENS.PROFILE; - params = { - username: get(profile, 'name'), - reputation: get(profile, 'reputation'), - deepLinkFilter, //TODO: process this in profile screen - }; - keey = get(profile, 'name'); - } else if (permlink === 'communities') { - routeName = ROUTES.SCREENS.WEB_BROWSER; - params = { - url: url, - }; - keey = 'WebBrowser'; - } else if (permlink) { - content = await getPost(author, permlink, currentAccount.name); - routeName = ROUTES.SCREENS.POST; - params = { - content, - }; - keey = `${author}/${permlink}`; - } + try{ + const deepLinkData = await deepLinkParser(url, currentAccount); + const { routeName, params, key } = deepLinkData || {}; + + if (routeName && key) { + navigate({ + routeName, + params, + key: key, + }); + } else { + throw new Error(intl.formatMessage({id:'deep_link.invalid_link'})) } - - if (feedType === 'hot' || feedType === 'trending' || feedType === 'created') { - if (!tag) { - routeName = ROUTES.SCREENS.TAG_RESULT; - } else if (/hive-[1-3]\d{4,6}$/.test(tag)) { - routeName = ROUTES.SCREENS.COMMUNITY; - } else { - routeName = ROUTES.SCREENS.TAG_RESULT; - } - params = { - tag, - filter: feedType, - }; - keey = `${feedType}/${tag || ''}`; - } - } catch (error) { - this._handleAlert('deep_link.no_existing_user'); - } - - if (!routeName) { - const { mode, referredUser } = parseAuthUrl(url); - if (mode === 'SIGNUP') { - routeName = ROUTES.SCREENS.REGISTER; - params = { - referredUser, - }; - keey = `${mode}/${referredUser || ''}`; - } - } - - if (routeName && keey) { - navigate({ - routeName, - params, - key: keey, - }); + } catch(err){ + this._handleAlert(err.message) } + }; _compareAndPromptForUpdate = async () => {