diff --git a/ios/eSteem/eSteem.entitlements b/ios/eSteem/eSteem.entitlements
index 92287ce49..821f58d27 100644
--- a/ios/eSteem/eSteem.entitlements
+++ b/ios/eSteem/eSteem.entitlements
@@ -10,6 +10,7 @@
applinks:busy.org
applinks:esteem.app
webcredentials:esteem.app
+ applinks:steem
diff --git a/src/providers/steem/auth.js b/src/providers/steem/auth.js
index bed82c30b..ac3b1e675 100644
--- a/src/providers/steem/auth.js
+++ b/src/providers/steem/auth.js
@@ -146,8 +146,7 @@ export const loginWithSC2 = async (access_token, pinCode) => {
await steemConnect.setAccessToken(access_token);
account = await steemConnect.me();
- console.log(account._id);
- console.log(account.name);
+ //console.log(account.name);
return new Promise((resolve, reject) => {
let userData = {
diff --git a/src/screens/login/login.js b/src/screens/login/login.js
index f30b717db..8b4b90d29 100644
--- a/src/screens/login/login.js
+++ b/src/screens/login/login.js
@@ -151,23 +151,17 @@ class LoginPage extends Component {
}
loginwithSc2 = () => {
- Navigation.showModal({
- stack: {
- children: [
- {
- component: {
- name: "navigation.eSteem.SteemConnect",
- passProps: {},
- options: {
- topBar: {
- title: {
- text: "Login via SC2",
- },
- },
- },
+ Navigation.push(this.props.componentId, {
+ component: {
+ name: "navigation.eSteem.SteemConnect",
+ passProps: {},
+ options: {
+ topBar: {
+ title: {
+ text: "Login via SC2",
},
},
- ],
+ },
},
});
};
diff --git a/src/screens/splash/splashContainer.js b/src/screens/splash/splashContainer.js
index 712499bfc..ed0e721ed 100644
--- a/src/screens/splash/splashContainer.js
+++ b/src/screens/splash/splashContainer.js
@@ -11,14 +11,19 @@ class SplashContainer extends React.Component {
super(props);
}
- async componentDidMount() {
- await getAuthStatus().then(res => {
- if (res) {
- goToNoAuthScreens();
- } else {
+ componentDidMount() {
+ getAuthStatus()
+ .then(result => {
+ if (result === true) {
+ goToAuthScreens();
+ } else {
+ goToNoAuthScreens();
+ }
+ })
+ .catch(error => {
+ console.log(error);
goToAuthScreens();
- }
- });
+ });
}
render() {
diff --git a/src/screens/steem-connect/config.js b/src/screens/steem-connect/config.js
index 12e834431..f615584df 100644
--- a/src/screens/steem-connect/config.js
+++ b/src/screens/steem-connect/config.js
@@ -1,7 +1,7 @@
export const steemConnectOptions = {
base_url: "https://steemconnect.com/oauth2/authorize",
client_id: "esteem-app",
- redirect_uri: "http%3A%2F%2F127.0.0.1%3A3415%2F", // http://127.0.0.1:3415
+ redirect_uri: "http://127.0.0.1:3415/", // http://127.0.0.1:3415
scope:
- "vote%2Ccomment%2Cdelete_comment%2Ccomment_options%2Ccustom_json%2Cclaim_reward_balance",
+ "vote,comment,delete_comment,comment_options,custom_json,claim_reward_balance",
};
diff --git a/src/screens/steem-connect/steemConnect.js b/src/screens/steem-connect/steemConnect.js
index 249a8c6e2..a34ece9c1 100644
--- a/src/screens/steem-connect/steemConnect.js
+++ b/src/screens/steem-connect/steemConnect.js
@@ -4,6 +4,7 @@ import { loginWithSC2 } from "../../providers/steem/auth";
import { steemConnectOptions } from "./config";
import RNRestart from "react-native-restart";
import { Navigation } from "react-native-navigation";
+import { goToAuthScreens } from "../../navigation";
export default class SteemConnect extends Component {
constructor(props) {
@@ -12,17 +13,31 @@ export default class SteemConnect extends Component {
}
onNavigationStateChange(event) {
- let access_token = event.url.match(
- /\?(?:access_token)\=([\S\s]*?)\&/
- )[1];
- if (access_token) {
- loginWithSC2(access_token, "pinCode").then(result => {
- if (result === true) {
- // TODO: Handle pinCode and navigate to home page
- } else {
- Navigation.dismissModal(this.props.componentId);
- }
- });
+ let access_token;
+ console.log(event.url);
+ if (event.url.indexOf("?access_token=") > -1) {
+ this.webview.stopLoading();
+ try {
+ access_token = event.url.match(
+ /\?(?:access_token)\=([\S\s]*?)\&/
+ )[1];
+ } catch (error) {
+ console.log(error);
+ }
+
+ loginWithSC2(access_token, "pinCode")
+ .then(result => {
+ if (result === true) {
+ // TODO: Handle pinCode and navigate to home page
+ goToAuthScreens();
+ } else {
+ // TODO: Error alert (Toast Message)
+ console.log("loginWithSC2 error");
+ }
+ })
+ .catch(error => {
+ console.log(error);
+ });
}
}
@@ -30,15 +45,18 @@ export default class SteemConnect extends Component {
return (
- this.onNavigationStateChange(state)
- }
source={{
uri: `${steemConnectOptions.base_url}?client_id=${
steemConnectOptions.client_id
- }&redirect_uri=${steemConnectOptions.redirect_uri}&${
- steemConnectOptions.scope
- }`,
+ }&redirect_uri=${encodeURIComponent(
+ steemConnectOptions.redirect_uri
+ )}&${encodeURIComponent(steemConnectOptions.scope)}`,
+ }}
+ onNavigationStateChange={this.onNavigationStateChange.bind(
+ this
+ )}
+ ref={ref => {
+ this.webview = ref;
}}
/>