diff --git a/.env b/.env index 3ff8ca822..9c78cc69b 100644 --- a/.env +++ b/.env @@ -5,10 +5,10 @@ # import { API_URL } from 'react-native-dotenv' # Same as MARKETING_VERSION in iOS / version in Android -APP_MARKETING_VERSION=0.13.0 +APP_MARKETING_VERSION=0.13.1 # Same as CURRENT_PROJECT_VERSION in iOS / version code in Android -APP_VERSION=155 +APP_VERSION=156 # APP_VERSION must be greater or equal to the this value # without forcing user to update the app diff --git a/android/app/build.gradle b/android/app/build.gradle index dea85d813..a0d4a8036 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,8 +138,8 @@ android { applicationId "com.oice" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 155 - versionName "0.13.0" + versionCode 156 + versionName "0.13.1" missingDimensionStrategy 'react-native-camera', 'general' } splits { diff --git a/app/screens/likerland-oauth-screen/likerland-oauth-screen.tsx b/app/screens/likerland-oauth-screen/likerland-oauth-screen.tsx index ce8e0ca28..b97f5ea86 100644 --- a/app/screens/likerland-oauth-screen/likerland-oauth-screen.tsx +++ b/app/screens/likerland-oauth-screen/likerland-oauth-screen.tsx @@ -5,6 +5,10 @@ import { } from "react-native" import { NavigationScreenProps } from "react-navigation" import { WebViewNavigation } from 'react-native-webview' +import { + WebViewErrorEvent, + WebViewHttpErrorEvent, +} from "react-native-webview/lib/WebViewTypes" import { inject } from "mobx-react" import { Style } from "./likerland-oauth-screen.style" @@ -19,28 +23,18 @@ import { RootStore } from "../../models/root-store" import { translate } from "../../i18n" import { COMMON_API_CONFIG } from "../../services/api/api-config" +import { logError } from "../../utils/error" export interface LikerLandOAuthScreenProps extends NavigationScreenProps<{}> { rootStore: RootStore, } @inject("rootStore") -export class LikerLandOAuthScreen extends React.Component { - private onNavigationStateChange = async (navState: WebViewNavigation) => { - const { url } = navState - const { rootStore } = this.props - if (url.includes("/following")) { - await Promise.all([ - this.props.rootStore.userStore.fetchUserInfo(), - this.props.rootStore.userStore.fetchLikerLandUserInfo(), - ]) - this.props.navigation.navigate("App") - - // Try to open the deferred deep link URL after sign in - rootStore.openDeepLink() - } else if (url.includes("/in/register")) { - this.handleError() - } +export class LikerLandOAuthScreen extends React.Component { + redirectTimer?: NodeJS.Timeout + + state = { + hasHandledRedirect: false, } private handleError = async () => { @@ -49,6 +43,39 @@ export class LikerLandOAuthScreen extends React.Component { + if (this.state.hasHandledRedirect) return + this.setState({ hasHandledRedirect: true }) + if (this.redirectTimer) { + clearTimeout(this.redirectTimer) + this.redirectTimer = undefined + } + await Promise.all([ + this.props.rootStore.userStore.fetchUserInfo(), + this.props.rootStore.userStore.fetchLikerLandUserInfo(), + ]) + this.props.navigation.navigate("App") + + // Try to open the deferred deep link URL after sign in + this.props.rootStore.openDeepLink() + } + + private handleURLChange = (url: string) => { + if (url.includes("/following")) { + this.handlePostSignIn() + } else if (url.includes("/oauth/redirect")) { + // Fallback to use timer if the above case not working + this.redirectTimer = setTimeout(this.handlePostSignIn, 2000) + } else if (url.includes("/in/register")) { + this.handleError() + logError("Error when signing in to liker.land, like.co shows register page") + } + } + + private onNavigationStateChange = ({ url }: WebViewNavigation) => { + this.handleURLChange(url) + } + private onWebviewError = () => { Alert.alert( translate("signInScreen.error"), @@ -62,6 +89,18 @@ export class LikerLandOAuthScreen extends React.Component { + this.onWebviewError() + const { code, description, url } = event.nativeEvent + logError(`Error occurs inside webview when signing in to liker.land ${JSON.stringify({ code, description, url })}`) + } + + private onHttpError = (event: WebViewHttpErrorEvent) => { + this.onWebviewError() + const { description, statusCode, url } = event.nativeEvent + logError(`HTTP error occurs inside webview when signing in to liker.land ${JSON.stringify({ description, statusCode, url })}`) + } + render () { const { signInURL, @@ -81,8 +120,8 @@ export class LikerLandOAuthScreen extends React.Component {this.renderLoadingOverlay()} diff --git a/ios/LikeCoinApp.xcodeproj/project.pbxproj b/ios/LikeCoinApp.xcodeproj/project.pbxproj index a406aeb22..bd3cbf6f8 100644 --- a/ios/LikeCoinApp.xcodeproj/project.pbxproj +++ b/ios/LikeCoinApp.xcodeproj/project.pbxproj @@ -703,12 +703,12 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = LikeCoinApp/LikeCoinApp.entitlements; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = 76UMR894HH; INFOPLIST_FILE = LikeCoinApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 0.13.0; + MARKETING_VERSION = 0.13.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -727,11 +727,11 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = LikeCoinApp/LikeCoinApp.entitlements; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEVELOPMENT_TEAM = 76UMR894HH; INFOPLIST_FILE = LikeCoinApp/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 0.13.0; + MARKETING_VERSION = 0.13.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/package.json b/package.json index 979d71ab3..7e35f4065 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "likecoin-app", - "version": "0.13.0", + "version": "0.13.1", "private": true, "scripts": { "start": "react-native start",