bradmartin / nativescript-advanced-webview

NativeScript plugin for Chrome CustomTabs on Android and SafariViewController on iOS.
Other
60 stars 28 forks source link

No event fires when browser closes #15

Closed itsjtwright closed 5 years ago

itsjtwright commented 7 years ago

Due to a bug with the app I am working on, there is an issue with screen orientation when coming back to the app from a browser window. If the app enters the safari view controller in portrait mode, in the SVC turns to landscape mode and then presses the 'done' button in the top left corner of the application, on return, the app still thinks it is in portrait mode.here is a <- picture of the problem. The app is not suspended when the browser opens, and I think that is what causes this problem. Is there any on an event that fires when the browser closes so I can force orient (using your other plugin) to portrait mode? Or a fix to this orientation problem as a whole?

bradmartin commented 7 years ago

There are events - just not wired up 😄 Android: https://developer.android.com/reference/android/support/customtabs/CustomTabsCallback.html iOS: haven't looked at yet but sure something exists for hooking into events.

If you want to help with a PR on these please let me know, I can help answer any questions along the way. Just not a lot of time to do all of it myself right now, in a few weeks I might have time to make the changes but no guarantee.

itsjtwright commented 7 years ago

So i found an event, that being safariviewcontrollerdidfinish, https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621214-safariviewcontrollerdidfinish is the link, but it does not fire when used like another event, I have it inside a UIApplicationsDelegate class but the console.log inside the safariviewcontrollerdidfinish does not fire when the done button is clicked.

itsjtwright commented 7 years ago

Inside your plugin you have it set to try to send a console log on ending an SFsafariviewcontroller and it does not fire, inside the file named advanced-webview.ios.ts.

bradmartin commented 7 years ago

@itsjtwright - yea I don't think I figured out how that piece when I worked on this. Might need to poke around for another NS plugin that uses a delegate and see how it's done. iOS is my weak spot :) I think the zendesk plugin uses a delegate for stuff on iOS. If you find something useful and wanna test let me know. I can help on the android side much quicker to get this implemented.

bradmartin commented 7 years ago

Right here is where I tried https://github.com/bradmartin/nativescript-advanced-webview/blob/master/advanced-webview.ios.ts#L45 - just don't think it worked when I tried this way.

itsjtwright commented 7 years ago

I asked on stack if you want to follow along if anyone ever answers https://stackoverflow.com/questions/44507073/sfsafariviewcontrollerdidfinish-event-hook-in-native-script

bradmartin commented 7 years ago

thanks it's definitely possible to do it :) just need some iOS help here

bradmartin commented 5 years ago

isClosed in the options object works as the callback for when the browser closes The demo has this working on both platforms with latest version.