What controls whether PhoneGap opens an external browser / Safari?

前端 未结 1 1025
南方客
南方客 2021-01-07 07:45

Sometimes PhoneGap opens web pages in Safari, sometimes it opens them in its UIWebView, what controls this?

相关标签:
1条回答
  • 2021-01-07 08:01

    From Does phoneGap support normal web?:

    https://github.com/callback/callback-ios/blob/master/PhoneGapLib/Classes/PhoneGapDelegate.m#L669 reveals that:

    1. if the URL has scheme gap:// it does not open Safari
    2. if the URL has scheme file:// it does not open Safari
    3. if the OpenAllWhitelistURLsInWebView policy is set it does not open Safari.
    4. if navigationType == UIWebViewNavigationTypeOther && mainDocument != nil then it does open Safari.

    Elaborating on 4:

    • ~NavTypeOther signifies that the navigation is not from: a link click, back/fwd button, reload, or form re/submission. (AKA window.location.href assignment, or window.open(...))
    • mainDocument != nil signifies that the link is not from an iFrame? and/or doesn't have a target?

    So basically, I think that only link clicks open in the UIWebView (unless they're gap:// or file:// links, or that policy is set.)

    0 讨论(0)
提交回复
热议问题