Remote Domains are not opening with Phonegap 3.1.0 - android

Really i have a serious problem with Phongap Build 3.1.0.
I added following code in config.xml(its under /myApp/platform/android/res/)
<access origin="http://google.com*" />
<content src="http://google.com" />
And when i open the APP its telling "The connection to the server was unsuccessfull. (http://google.com)"
Suppose if i open the URL with inAppBrowser its opening without any error.
var ref = window.open('http://google.com', '_blank', 'location=no');

Try putting this in your config.xml under www
<content src="index.html" />
<access origin="http://127.0.0.1*" />
<access origin="http://*.google.com" />

I encountered a similar problem with 3.1 and found it's because 3.1 changed the whitelisting syntax, as documented here: http://docs.phonegap.com/en/3.1.0/guide_appdev_whitelist_index.md.html
Try this:
<access origin="*://*.google.com/*" subdomains="true" />

Related

PhoneGap - inappbrowser not working - Need to open the URL inside the app

There are so many questions related to this like, Phonegap - How to open external link inside the app .
I want to open the website URL inside the app (not asking which browser need to open) when open the app.
But it asked which browser you need to open.... What I have done mistake here? (This is working fine on emulator, but when I install it to android phone it asked which browser......)
My config file
<access origin="*" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.2" />
<plugin name="cordova-plugin-inappbrowser" spec="~1.7.2" />
Index File
<script>
window.open('http://example.com', '_self', 'location=no,hidden=yes,closebuttoncaption=Done,toolbar=no');
</script>
You have to configure the whitelist plugin to allow the internal navigation of external sites, you can do it with allow-navigation tag like this:
<allow-navigation href="*" />

tel and mailto Links Stopped Working in cordova app

I developing hybrid mobile application with help of cordova.
I am using cordova version 7.0.1, tel & mailto links are not working in android app, below is the code.
+44 20 7939 8514
gsc#travelsecurity.com
for this have update following changes,
added inappbrowser plugin, updated config.xml,
<access origin="*" />
<access launch-external="yes" origin="mailto:*" />
<access launch-external="yes" origin="tel:*" />
Please check where I did wrong and let me know.
Thanks in advance!
I ran into the same bug today.
Fixed it by sending the emails like this:
window.open('mailto:john#doe.com?body=test", '_system');

Android - Scheduling Local Notifications on PhoneGap Build / Apache Cordova 4.1.1

I'm having issues trying to schedule local notifications on an Android app (using PhoneGap build).
I'm trying to schedule a local notification at a set date and time (e.g. September 23rd 2016 at 12:00pm).
I've tried using the following plugin:
https://build.phonegap.com/plugins/2081
My config.xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id = "****"
versionCode = "292000"
version = "2.9.2" >
<gap:config-file platform="android" parent="/manifest">
<application android:debuggable="true" />
</gap:config-file>
<!-- versionCode is optional and Android only -->
<name>****</name>
<description>
****
</description>
<author href="****" email="****">
****
</author>
<icon src="icon.png" />
<allow-navigation href="*" />
<access origin="*" />
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="23"/>
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
</widget>
I then schedule the notification using the code below:
cordova.plugins.notification.local.schedule({
title: $title,
text: $message,
at: $date
});
When building for the latest PhoneGap version (cli-6.3.0), I get the following error on the build.phonegap.com site:
Error - Some official plugins have to be updated if using PhoneGap >= 4.0.0. Please upgrade the version of any plugins that may include the following file: LocalNotification.java
It seems that the plugin has not been updated for the latest version of PhoneGap causing the build to fail.
I've tried building for the latest supported version of the plugin (PhoneGap 3.7.0). The build completes successfully and when installed directly on an Android device, everything works correctly. The notifications fire as scheduled.
However, when trying to submit this build to the Google Play store, the build is rejected with the following error:
Your APK has been rejected for containing security vulnerabilities, which violates the Malicious Behavior policy. The Alerts page has more information about how to resolve the issue. If you submitted an update, the previous version of your app is still live on Google Play.
The build now needs to use v4.1.1 of Apache Cordova to be accepted by the Google Play .
I've looked around but can't find a solution anywhere. Is anyone aware of a fix, or alternatively, a different plugin that allows scheduling of local notifications on Android supporting Apache Cordova v4.1.1 or above?
Change
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
to
<plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="npm" />
I have fixed myself.
Changing the plugin name will work.
We need to find an appropriate plugin and replace older version in config.xml.
In my case, I have changed
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="pgb" />
to
<gap:plugin name="trunk.plugin.local-notification" />

Phonegap tel: uri not working on android even after whitelisting

html5 jquery mobile hybrid phonegap app on android s6 sport using phonegap desktop and phonegap developer app on phone. Not sure of phone gap version (cli not installed properly, tried but opening prompt gives an error) but it is a recent (last week) install.
Using call in chrome opens phone app dialer but not in test phonegap app - click does nothing. Also mailto: and http: acts the same, works in chrome not in app.
The exact html is:
<a id="btn_phone" href="tel:18001231234" rel="external" data-role="button" data-icon="phone"></a>
I added to the config.xml
and based on comments removed the catch-all
which got it working for others but not in my case.
In config file is this:
<access origin="tel:*" launch-external="yes"/>
<access origin="geo:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
<access origin="sms:*" launch-external="yes"/>
<plugin name="cordova-plugin-whitelist" version="1"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
as stated I removed this:
<access origin="*"/>
So based on everything I've read that should be all I need to do but it is still not working.
Two questions:
Does anyone know a fix for this?
Is there a way to debug this on the phone to see what is failing?
thanks
I struggled with this forever and eventually did the following which worked:
In the HTML:
<input type="button" href="tel:+1-800-555-1234“ class="phone-number" value="1-800-555-1234"/>
In the Javascript:
$(‘.phone-number’).bind(click, function(e) {
e.preventDefault()
var phoneLink = $(e.currentTarget).attr('href');
window.open(phoneLink, '_system', 'location=yes’);
}
What is your cordova version? I think your problem is the white list plugin declaration.
Try this:
<feature name="Whitelist">
<param name="android-package" value="YOUR_WHITELIST_CORDOVA_PATH" />
<param name="onload" value="true" />
</feature>
More info on how to configure White List here: https://www.npmjs.com/package/cordova-plugin-whitelist
NOTE TO ALL This answer does NOT work for CLI. <feature> in this context is meant for SDK and those using an IDE. See Documentation The feature Element
Quote:
If you use the CLI to build applications, you use the plugin command to enable device APIs. This does not modify the top-level config.xml file, so the <feature> element does not apply to your workflow.
If you work directly in an SDK and using the platform-specific config.xml file as source, you use the <feature> tag to enable device-level APIs and external plugins. They often appear with custom values in platform-specific config.xml files.

How to embed Youtube video in Cordova Android app

I am new to Cordova App development.
I have a Youtube URL and I want to embed the video in Cordova app. I have tried making it with YouTube Api(JS Library) and with iframe also. What do I have to do to make the video load on the Android app?
For me, the solution was editing config.xml file adding the following lines:
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<allow-navigation href="*youtube*" />
<allow-navigation href="*ytimg*" />
<allow-navigation href="*youtube-nocookie*" />
Using iframe is the preferred and suggested way to embed youtube videos, so this is how you need to proceed. The getting started code from the YoutTube iframe API reference loads and works in both iOS (tested on iOS 7) and Android (tested on Android 4.3).
Adding the parameter feature=player_embedded to the iframe url worked fine for me:
<iframe width="640" height="360" src="http://www.youtube.com/embed/*********?feature=player_embedded" frameborder="0" allowfullscreen></iframe>
Unless you are using <access origin="*" /> (not recommended) you will need to allow the following domains with your config.xml to embed youtube videos in an cordova android app:
<access origin="https://*.youtube-nocookie.com" />
<access origin="https://*.youtube.com" />
<access origin="https://*.ytimg.com" />
<access origin="https://*.gstatic.com" />
<access origin="https://*.googlevideo.com" />
<access origin="https://*.google.com" />
This is for use with the privacy-enhanced embed mode. The youtube-nocookie domain presumably is not needed for a standard embed.
If you use a content security meta tag you will also need to allow those domains in your csp.

Categories

Resources