In my phonegap iPhone app, while i am trying to load a html with google maps acces using sencha-touch. A notification shows "/iphone simulator/...../index.html access your Location" . How can i change the html file name to application name?.
Make sure you are calling "navigator.geolocation.getCurrentPosition" after phonegap initialization is done. So for example:
document.addEventListener('deviceready', function () {
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
}, false);
If that still doesn't do the trick, try adding a delay.
Related
I am using google places api in ionic app.I places google places api script in index.html. The app allow the user to access wifi within specific place. User get internet access after login with our app. When application launch and user is connecting with our network, user do not have access to the internet. So i get error:
Application Error connection to the server was unsuccessful.
Is there anyway to call the google places api after user has access to the internet to avoid the error?
This has been quickly tested in ionic 1 and it works, no reason it shouldn't in ionic 2. But if you know a proper way to add the script tag in angular, just replace this part. The logic is simply to add your resource on the fly to index.html. Don't forget that connexion can appear while app is already started, and that you don't need to add the tag twice (verifications have to be done). Some edits might be done to adapt to ionic 2, sorry my version was made on the 1.
the function to add the script:
function addScriptTag(){
//STORE HERE VALUE TO VERIFY SCRIPT HAS ALREADY BEEN ADDED
var script = document.createElement('script');
script.src = 'http://maps.google.com...';
script.type = 'text/javascript';
document.head.appendChild(script);
}
in $ionicPlatform.ready (network is not available before that)
//CONNECTED AT APP LOADING
var networkState = navigator.connection.type;
if(networkState !== Connection.NONE){
addScriptTag();
}
//IN CASE CONNEXION ARRIVES LATER
$rootScope.$on('$cordovaNetwork:online', function(event, networkState){
if( /* VERIFY SCRIPT NOT ADDED BEFORE */ ){
addScriptTag();
}
}, false);
I am trying to create a facebook app with a google apps script application inside it.
for example,
my google script address is https://script.google.com/macros/s/ABCDEFGHIJKLMNOPQRSDUVWXYZ/exec ,
which I can access by web browser without problems.
Inside the script, I've designed both doGet() and doPost() with simple HTML output return:
function doGet(request){
Logger.log("[GET]");
Logger.log(request);
return HtmlService.createHtmlOutput(<html><head></head><body>Hello World</body></html>);
}
function doPost(request){
Logger.log("[POST]");
Logger.log(request);
return HtmlService.createHtmlOutput(<html><head></head><body>Hello World</body></html>);
}
and set my fabebook app canvas url to
"http://script.google.com/macros/s/ABCDEFGHIJKLMNOPQRSDUVWXYZ/exec?"
and
"https://script.google.com/macros/s/ABCDEFGHIJKLMNOPQRSDUVWXYZ/exec?"
But facebook app page responsed nothing.
In my google script logger, apparently it has been access by method POST:
[13-07-06 15:46:19:641 HKT] [POST]
[13-07-06 15:46:19:647 HKT] {queryString=null, postData=FileUpload, parameter=
{signed_request=
ABwQlxIQ8qCMleUj1oomKszLWeKclO56lya5uOfdizA.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM3MzA5Njc3OCwidXNlciI6eyJjb3VudHJ5IjoidHciLCJsb2NhbGUiOiJ6aF9UVyIsImFnZSI6eyJtaW4iOjIxfX19
},contextPath=, parameters={signed_request=
[ABwQlxIQ8qCMleUj1oomKszLWeKclO56lya5uOfdizA.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM3MzA5Njc3OCwidXNlciI6eyJjb3VudHJ5IjoidHciLCJsb2NhbGUiOiJ6aF9UVyIsImFnZSI6eyJtaW4iOjIxfX19]
}, contentLength=203}
I have also tried ContentService, UiApp but still failed.
It is not possible to embed Google App Script in another page. App script page adds x-frame-origin header which makes it not possible to embed.
hi all i am a new iphone developer. i am working on webview application from my URL i am getting alerts in the web browser but same url not showing alerts in the iphone web view as like web browser. how to apply the java script coding alerts in the iphone web view?. thank you in advance.
If the Javascript is yours then instead of calling the alert you could instead call a function that calls Objective C and invoke an iOS native alert.
If the Javascript isn't yours then using UIWebView you can inject some Javascript to override the default behaviour and change it to call an iOS native alert i.e. something like this
window.alert = function(message) {
window.location = "myScheme://" + message"
};
Then look for myScheme and extract message in UIWebView's shouldStartLoadWithRequest
I am new to phonegap and iPhone development, and am trying to get phonegap's index.html to redirect to a JQuery Mobile site that is located externally at a settings based URL which I have in my Settings.bundle, Root.plist, Server URL. I have my index.html page redirecting to a hard coded server in the index.html file, but how do I get it to go to the URL that I have in my application settings?
Thanks in advance for any help in steering me in the right direction
I've been trying to get the plugin applicationPreferences working to essentially do something similar. Currently to no avail. As soon as I come up with a solution I will post something here again.
UPDATE
This does work it seems. There is a small, nearly unnoticeable error in the readme example.
There needs to be a comma after the 'homer'.
¬
window.plugins.applicationPreferences.set('name_identifier','homer', function() {
alert("It is saved");
}, function(error) {
alert("Failed to retrieve a setting: " + error);
}
);
For our iPhone native application we have a URL : example://
On the iPhone if I type this URL (example://) in safari it automatically opens up my application.
From my "regular" website I have a link which when the user clicks it opens the application. The problem is that if the application is not installed on the iPhone it throws "Unable to open" error.
So before rendering the link on my "regular" site I need to check if the app is installed, one solution is to make an Ajax call and check for status code:
$.ajax({
type: 'POST',
url: 'example://',
complete: function (transport) {
if (transport.status == 200) {
alert('Success');
} else {
alert(transport.status);
alert('Failed');
}
}
});
But this code is always returning a status code "0".
Is there a way to find out from the web if the native iPhone app is installed?
If u are referring to Mobile Safari, you're out of luck. There's no documented public API that I know of that can do this. Mobile Safari is sandboxed away from the OS.
If it's in a webview within an app, u can request the URL and let the webview delegate talk to the native app / query the handling of example://. Otherwise, no way the browser can know existence of any installed app.