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?
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.
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.
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.
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.
Solution:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With