Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to use the InAppBrowser plugin for Phonegap 3.1 on iOS 7

I'm in the process of porting an iOS app I built using Phonegap to iOS7 with Phonegap 3.1 and I've run into a little issue.

iOS 7 seems to have made some significant changes in that hyperlinks with the target="_blank" attribute are now opened by default within the app itself, rather than in the system browser (this doesn't seem to happen on Android, or previous versions of iOS, however). This has broken some of the functionality of the app, and I need to correct this.

Using the InAppBrowser plugin seems like the way to go, so I've installed the plugin. I've amended my config.xml to include this:

<feature name="InAppBrowser">
        <param name="ios-package" value="CDVInAppBrowser" />
</feature>

And the link in the template now looks like this (please note I'm using Handlebars as the templating system here):

<a href="#" onclick="window.externalbrowser = window.open('{{this.url}}, ', '_system', 'location=yes');" data-transition="slide">
    <img alt="Favicon" style="border: 1px solid #ccc;" title="Favicon" class="ui-li-icon" src="{{this.favicon_url}}"></img>
    <p style="font-size: 100%"><strong>Submitted {{this.whenSubmitted}}</strong><br />Last changed {{this.lastChanged}}</p>
</a>

Whenever I click the link, it fails to open and I get the following error appear in the logs:

Plugin 'InAppBrowser' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2013-11-08 10:22:56.753 MyApp[197:60b] -[CDVCommandQueue executePending] [Line 117] FAILED pluginJSON = [
  "InAppBrowser814285423",
  "InAppBrowser",
  "open",
  [
    "http:\/\/www.site.co.uk\/deals-offers-savings\/b?ie=UTF8&node=350613011&tag=page0e-21,",
    "_system",
    "location=yes"
  ]
]

There are also a number of deprecation warnings about the CDVInAppBrowser.m source file.

I can't for the life of me see why the plugin is not being picked up. Can anyone else suggest what the issue might be?

like image 618
Matthew Daly Avatar asked Nov 08 '13 11:11

Matthew Daly


People also ask

What is Cordova plugin InAppBrowser?

You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app. To get a few ideas, check out the sample at the bottom of this page or go straight to the reference content.

What is InAppBrowser?

The InAppBrowser is a web browser view that displays when calling [window. open](window. open. html)() , or when opening a link formed as <a target="_blank"> . var ref = window.

How do I close InAppBrowser?

There is no action to close the InAppBrowser. How can we achieve this? The user is redirected to an aws login page in the IAB and after suscessfull login the IAB should close and the user should be redirected to a screen in the app.


1 Answers

I found a true solution for this without having to recreate the project. based on this answer: similar question and answer

It appears that this happens because sometimes the xcode project files aren't update after adding/removing plugins. All the files are in place, and the config.xml is in order but the xcode project fails to mark the new plugin files as targetting the application.

enter image description here

Solution:

  1. Open your project in xcode
  2. Navigate to the plugin file in question (CDV*.m file)
  3. On the right hand menu, under the "Target Membership" section make sure the checkbox is checked for your application.

enter image description here

like image 100
Barryrowe Avatar answered Oct 20 '22 00:10

Barryrowe