Created
September 13, 2017 18:00
-
-
Save mgenov/dda16f6f4c46c7b23807655bc122f065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return new Promise((resolve, reject) => { | |
Linking.openURL(url.join('')) | |
.then(() => { | |
const handleUrl = url => { | |
if (!url || url.indexOf('fail') > -1) { | |
reject(url) | |
} else { | |
resolve(url) | |
} | |
} | |
const onLinkChange = ({ url }) => { | |
Linking.removeEventListener('url', onLinkChange) | |
console.log('changed url: ', url) | |
// Linking.openURL('https://google.com').then(response => { | |
// console.log('got reponse from server: ', response) | |
// }) | |
handleUrl(url) | |
} | |
Linking.addEventListener('url', onLinkChange) | |
}) | |
.catch(error => { | |
console.log('got error') | |
reject(error) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment