cordova-plugin-safariviewcontroller
cordova-plugin-safariviewcontroller copied to clipboard
"hide" method is not yet implemented for Android
Hi i am trying to hide my safariViewController using safariViewController.hide(). but it is throwing error: "Invalid action". Help me.
Share your code please.
Hi Eddy, i am working on ionic2. here is my code
this.safariViewController.isAvailable() .then((available: boolean) => {
if (available) { console.log('safari view test start'); this.safariViewController.show({ url: data.link, hidden: false, animated: false, transition: 'curl', enterReaderModeIfAvailable: true, tintColor: '#ff0000' }) .then((result: any) => { console.log("result*****: "+JSON.stringify(result)); if(result.event === 'opened') { console.log('Opened'); console.log("data"); console.log("data: "+JSON.stringify(data)); setTimeout(function() { console.log('TESTTTT'); this.safariViewController.hide(); }, 5000);
}
else if(result.event === 'loaded'){
console.log('Loaded');
}
else if(result.event === 'closed') console.log('Closed');
}, (error: any) => console.error(error) ); console.log('safari view test');
} else { // use fallback browser, example InAppBrowser }
});
On Wed, Apr 5, 2017 at 12:14 PM, Eddy Verbruggen [email protected] wrote:
Share your code please.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller/issues/62#issuecomment-291769410, or mute the thread https://github.com/notifications/unsubscribe-auth/AWmhs5ihVj-B11oqrQqxWzQNtjlVShf3ks5rszhMgaJpZM4MzztL .
Could it be the context of this
is lost after the timeout? So this.safariViewController.hide
will no longer work.
Looks like you're using TS, so perhaps try this instead, as arrow functions keep track of this
for you:
setTimeout(() => {
console.log('TESTTTT');
this.safariViewController.hide();
}, 5000);
If that works you can donate me some 🍺 on my Paypal :)
nope context of "this" ll not be lost throughout my function. same is working fine for me in IOS but it throws error in android.
On Wed, Apr 5, 2017 at 5:24 PM, Eddy Verbruggen [email protected] wrote:
Could it be the context of this is lost after the timeout? So this.safariViewController.hide will no longer work.
Looks like you're using TS, so perhaps try this instead, as arrow functions keep track of this for you:
setTimeout(() => { console.log('TESTTTT'); this.safariViewController.hide(); }, 5000);
If that works you can donate me some 🍺 on my Paypal :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller/issues/62#issuecomment-291838148, or mute the thread https://github.com/notifications/unsubscribe-auth/AWmhs9n8oPh3AXRiKeZY7jWUrlWJgbFgks5rs4DcgaJpZM4MzztL .
You're right, hide
wasn't implemented on Android. I didn't provide the Android implementation so I don't know why not. Perhaps it's not possible even.
Turning this into a feature request.
okay thank you Eddy for your response :)
On Thu, Apr 6, 2017 at 6:54 PM, Eddy Verbruggen [email protected] wrote:
You're right, hide wasn't implemented on Android. I didn't provide the Android implementation so I don't know why not. Perhaps it's not possible even.
Turning this into a feature request.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller/issues/62#issuecomment-292173299, or mute the thread https://github.com/notifications/unsubscribe-auth/AWmhs_UPihDhCw9YPpaB1KO40JPvRmsgks5rtOeVgaJpZM4MzztL .
Hello!
What is the status of this issue? Is it possible that the "hide" method in Android will be implemented in the next release?
Thanks in advance!
You're welcome to give it a shot if you need it. I personally don't, so..
@Dimigergo, @binita12345 did any of you manage to implement this for Android ? If so, please share.
For my purpose (an oauth authentication), applying the changes described in https://stackoverflow.com/questions/42530178/auto-close-chrome-custom-tab#42530510 closes Android's custom tab after redirecting to the app, which is exactly what I needed.
The changes done are:
-
add the following line to config.xml:
<preference name="AndroidLaunchMode" value="singleTop" />
-
add the following lines at the begining of startCustomTabActivity in plugins/cordova-plugin-safariviewcontroller/src/android/ChromeCustomTabPlugin.java:
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Refer to https://bugs.chromium.org/p/chromium/issues/detail?id=543542 , https://bugs.chromium.org/p/chromium/issues/detail?id=545446 , and https://stackoverflow.com/questions/42530178/auto-close-chrome-custom-tab for more information.
Actually, applying the first change, by adding the preference to config.xml seems to be enough to automatically close the tab when redirecting to the app.
Is it possible to implement just a dummy action for android so the exception does not occur anymore?