react-native-simple-auth
react-native-simple-auth copied to clipboard
Upon launching the app, a web page in mobile Safari opens firs
We noticed an issue in your app that contributes to a lower quality user experience than Apple users expect:
 - Upon launching the app, a web page in mobile Safari opens first, then returns to the app. The user should be able to use the app immediately upon launch.
Next Steps
To resolve this issue, please revise your app to address all instances of this type of issue.
已经用react-native-safari-view配合解决
react-native.js
import {
Linking,
Platform
} from 'react-native'; // eslint-disable-line import/no-unresolved, max-len
import SafariView from 'react-native-safari-view';
let previousOnLinkChange;
export const dance = (authUrl) => {
// Use SafariView on iOS
if (Platform.OS === 'ios') {
if (previousOnLinkChange) {
Linking.removeEventListener('url', previousOnLinkChange);
}
return SafariView.show({
url: authUrl,
readerMode: false,
fromBottom: true,
tintColor: '#000',
barTintColor: '#fff'
}).then(() => new Promise((resolve, reject) => {
const handleUrl = (url) => {
if (!url || url.indexOf('fail') > -1) {
reject(url);
} else {
resolve(url);
}
SafariView.dismiss();
};
const onLinkChange = ({url}) => {
Linking.removeEventListener('url', onLinkChange);
previousOnLinkChange = undefined;
handleUrl(url);
};
Linking.addEventListener('url', onLinkChange);
previousOnLinkChange = onLinkChange;
}));
}
// Or Linking.openURL on Android
else {
if (previousOnLinkChange) {
Linking.removeEventListener('url', previousOnLinkChange);
}
return Linking.openURL(authUrl)
.then(() => new Promise((resolve, reject) => {
const handleUrl = (url) => {
if (!url || url.indexOf('fail') > -1) {
reject(url);
} else {
resolve(url);
}
};
const onLinkChange = ({url}) => {
Linking.removeEventListener('url', onLinkChange);
previousOnLinkChange = undefined;
handleUrl(url);
};
Linking.addEventListener('url', onLinkChange);
previousOnLinkChange = onLinkChange;
}));
}
};
export const request = fetch;
@bashen1 same message came for me also. did the above solution worked for you ?
@ayushnawani Yes
@bashen1 you should create one pull request so it can be merged. @adamjmcgrath is it possible?
Sure, happy to look at a PR. Although see my comment https://github.com/adamjmcgrath/react-native-simple-auth/pull/86#issuecomment-352185403 about including react-native-safari-view