How to make a phonegap application point to a certain URL? - ios

I found other questions about this and I tried the suggested answers which were as follows.
Adjust the config.xml file:
I changed this <content src="index.html" /> to <content src="localhost:3000" />
and also
<access origin="*" /> to </content src="localhost:3000" subdomains="true">
But everytime I launch my application, it is still referring to the index.html file.
I am only trying it on iOS platform.
For testing purposes, I am trying the webpage online everytime, I launch the application using phonegap serve form the CLI, the webpage (localhost:3000), still refers to index.html
Any insights on that?

You cannot point a device to localhost as localhost is an alias of 127.0.0.1 which is not reachable over a network.
You need to point to the actual IP address of the machine that is hosting your code.
Example:
<content src="192.75.64.231:3000" subdomains="true" />

Related

Configure apple-app-site-association file and upload on server

I am new on iOS development. I am implementing Universal Links in iOS App with ASP.net application.
I have define my associate domain in capabilities under Associated Domains:
applinks:www.abcd.com
And also configure in App Ids on Apple Developer Account. I think app side work is all set .
But I think problem with apple-app-site-association file.
I have written json in a simple text file like below
{
"applinks": {
"apps": [],
"details": [
{
"appID": "8T8932TY.com.AppNameā€,
"paths": ["*"]
}
]
}
}
Now I am stuck here. My application targeting on iOS 9 and above. I am confused that what is the extension of this file with naming apple-app-site-association. If I need to signed in with new certificates or not. And how upload it on server side.
Please guys help me out. I am searching lot for this but not get satisfactory answer.
Thanks
Your example JSON looks fine if substituted with real values for the AppID/AppName. You may want to be specific about what routes you handle but that's up to you - it's a better user experience to only try to handle routes that there's some chance you'll be able to handle, rather than opening your app for every link on your domain and kicking the user out to Safari again if that turns out not to be true.
The apple-app-site-association file should not have any file extension, and should be served from the root of your site, https://example.com/apple-app-site-association, and/or from https://example.com/.well-known/apple-app-site-association.
You say you're supporting iOS 9 and above - the change to check the .well-known route, which is checked first, came in iOS 9.3, so if you want to support below that OS, you're best off putting the file in both locations. See this answer for details.
It's also important that the file is served with the correct MIME-type, for Universal Links it can be served as application/json, and there's no need to sign/encrypt it. Getting it served with the correct MIME-type can be a little annoying if you're not familiar with configuration on your web server, as typically servers will determine the MIME-type from the file extension. You can't give it an extension, as iOS won't check the url with an extension and (IIRC) redirects are not allowed so you can't fake it by doing that either.
So that's a summary of what you're trying to accomplish, but how you do that depends on the web server you're using. For an ASP app that's likely to be IIS, in which case this question and its answers may help you configure your web server correctly. The details of how you upload a file to the root of that server will very much depend on how you've configured it as well.
There is no extension for this apple-app-site-association file. This is just a plain file. You have to host it on the top level of your domain meaning the file location will be https://www.abcd.com/apple-app-site-association Once you host it you can check/validate by using this link https://branch.io/resources/aasa-validator/
For detailed info please refer: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/
This worked for me.
Created an empty .NET Core project and deployed it to the corresponding Azure web app service.
Using, Advanced tools in Azure portal, nvaigated to the Kudu files of the deployed app service.
Inside the folder "site/wwwroot/wwwroot" created a new folder named ".well-known".
Inside the newly created folder, created a new file named "apple-app-site-association.json".
Edited the newly created json file to hold the app details.
Modifed the file "site/wwwroot/web.config" for the following reasons:
a) Since iOS always calls the URLs without file extension mentioned (https://webapp-sftpint-employeeapp-dev.azurewebsites.net/apple-app-site-association)
we need to forcefully reqrite such URLs to have the file extension. Hence, added the rule in web.config
b) Since the response header should have "application/json" for the content returned from the static file "apple-app-site-association.json",
we added the explicit mentioning of the mimeType as "application/json".
So, the web.config file looks somewhat like this. (only the 'rewrite' and 'staticContent' blocks needs to be added additionally)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\yourproject.dll" stdoutLogEnabled="false" stdoutLogFile=\\?\%home%\LogFiles\stdout hostingModel="inprocess" />
<rewrite>
<rules>`enter code here`
<rule name="apple_json_file">
<match url="^apple-app-site-association" />
<action type="Rewrite" url=".well-known/apple-app-site-association.json" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</location>
</configuration>

Angular $templateCache and $stateProvider fix for native ios phonegap/cordova

Angular $templateCache, $stateProvider and ng-include works beautifully in a web browser, but on native ios using phonegap/cordova it won't load templates or go to states
I've gone through the checklist:
remove <base href="/">
make sure paths are relative "template.html"
vs "/template.html"
make sure html5Mode is false
load templates.js before angular
make sure dependency injections are in place
Here are some examples of what works in a browser but not on native ios.
$stateProvider.state('start', {
url: '',
templateUrl: 'templates/start/start.html'
});
and
$state.go('start');
and
<div ng-include=" 'fileFromTemplatecache.html' "></div>
Any idea? I can't find a solution that works.
Others will come across this issue I'm sure. The solution has to do with the config.xml file at the root of your mobile build. This is what worked for me...
<allow-navigation href="file://*/*"/>
<allow-navigation href="*"/>
<allow-intent href="file://*/*"/>
<allow-intent href="*"/>
<access origin="file://*/*"/>
<access origin="*"/>

How to whitelist unknown domains in blackberry 10 and webworks sdk?

I know that to access an external link, one has to whitelist the access path in config.xml.
My problem is that I am unable to use asterisk as the whitelist option. Ripple emulator does not let me do it. My app downloads a number of image links and then display those images. These images could come from any number of sources/ domains. Now how do I mention an intelligent whitelist for this purpose?
My Environment:
BlackBerry 10 WebWorks SDK 1.0.4.11
BB10 Simulator
Windows 7
The way you do that is adding this line in the config.xml file:
<access subdomains="true" uri="*" />
But there's a quirk that renders this option useless whenever you use ajax. From the docs:
You can specify a wildcard () for the uri to whitelist any domain, but only for domains that do not access application APIs and that do not access content through XMLHttpRequest. If the domain requires access to APIs or accesses data through XMLHttpRequest, you must explicitly specify the domain in the uri.*
As Mister Smith said above, the proper way to 'whitelist' a domain is by adding the wildcard access element to your config.xml
<access subdomains="true" uri="*" />
You also have the ability to disable all web-security. While this is not the first recommended approach to dealing with cross origin requests, it's sometimes needed, especially when talking to services that use a CDN. To disable all web-security you'll want to add the following to your config.xml
<feature id="blackberry.app" >
<param name="websecurity" value="disable" />
</feature>
Lastly, your Ripple issue is something separate from all of this.
Go to manage your Chrome extensions, find Rippe, and check the box that says "Allow access to file URLs", and add the following flag to your Chrome shortcut --allow-access-from-files

open html file on sdcard with phonegap and jquery mobile

i have some HTML files that users can download in runtime to sdcard. Now i want to create a link in my app to open those files. The problem is, i do not know what i should write in href property of the link tags to open the HTML files on sdcard
can anyone help me?
In the congif.xml file from my Blackberry app project locate on:
C:\Dev\phonegap\BlackBerry-WebWorks\<project_folder>\www
there are this lines:
<!-- PhoneGap API -->
<access subdomains="true" uri="file:///store/home" />
<access subdomains="true" uri="file:///SDCard" />
That config is granting access to those URI/resources, i think you can play around with that.
I have no idea how will be this URI on other plataforms, but is a good point to start the testing,
Good Luck!

Phone Gap , Blackberry environment reference external JS file

I am using Phone Gap Blackberry environment for creating apps targeted OS6.0 & above.
In the index.html, inside the head tag i am referencing the external JS file, which actually contains the data needed for my application.
EG: www. google .com/js/data.js
In the project config.xml i have also referenced the the site
EG:< access subdomains="true" uri="http :// www.google.com" />
The issue here is, i dont see the data.js file being called. This works fine with Android & Iphone environment.
Am i doing something wrong here???
In your config.xml, you need to also provide access to the google.com domain, otherwise your app won't get access to google.com and won't be able to download the script file. From your post, it looks like you only provided access to nyigf.com.
You need to add an additional element to your config.xml, i.e.
<access subdomains="true" uri="http://www.google.com" />

Resources