I'm developing an web app for Windows Phone 7 using jquery mobile.
I want to navigate to a page say index.html to sample.html.
function sample()
{
window.location.href = "Sample.html";
navigator.notification.alert("Navigated);
}
It works fine.
But when a querystring is added with "sample.html?id=123123"
function sample()
{
window.location.href = "Sample.html?id=123123";
navigator.notification.alert("Navigated");
}
This navigation does not work.
Can anyone please guide.Anyother navigation method along with querystring is also welcome.
We can not use a querystring in web application using phonegap for windows phone 7.
Instead we can use Sample.html#12312
What is txt? It looks like it might be throwing an exception when you try to access txt.value, because txt is null. I assume it is a textbox on the page, so you'd have to access it like $("input#txt").val(); instead
In a PhoneGap Windows Phone application it should be like:
document.location = "Sample.html#id=123123";
Or:
window.location.href = "Sample.html#id=123123";
Related
I would like to create a web-page, a page that will redirect to App Store if App is not installed in iPhone, and will redirect to The App if App is installed in iPhone.
I wrote Javascript like below.
function launchApp(){
let URI_SCHEME = 'myapp://';
let APP_STORE_URL = 'https://itunes.apple.com/jp/app/myapp/id111111111';
let userAgent = navigator.userAgent.toLowerCase();
if(userAgent.search(/iphone|ipad|ipod/) > -1){
location.href = URI_SCHEME;
setTimeout(function (){
let aTag = document.createElement('a');
aTag.href = APP_STORE_URL;
aTag.Click();
}, 1200)
}
}
I tried this code, and in iOS Safari, it works as I expected.
However, in iOS Chrome app, it does not work.
To be more specific, when I tap the link button to the page that I am creating, the new tab opens but closes immediately.
Does anyone know why it does not work in iOS Chrome app?
Moreover, does anyone know better solution?
Thank you for your cooperation.
In my Ionic Application, I need to open my other application link in Play store.
I have tried following so far :
window.open('market://details?id=com.myapp.something', '_self')
And
window.open('market://details?id=com.myapp.something', '_system', 'location=no');
Above links opens in InnAppBrowser, I need them to open in playstore itself.
Any suggestions?
I found that you can open it in your system Browser with Package ID and it will automatically redirect you to respective application store.
$window.open("https://play.google.com/store/apps/details?id=your-app-package-name&hl=en","_system");
This worked for me the best.
EDIT :
There is a plugin available which might help : Launch Review
Redirect IONIC application to play store
window.open("https://play.google.com/store/apps/details?id=com.carClient.bookMyDreamCar","_system");
open playstore in your application
window.location.assign('https://play.google.com/store/apps/details?id=com.carClient.bookMyDreamCar')
If you want to open market apps for rating reviews then will be better to use this plugin instead
Ionic V3: https://ionicframework.com/docs/v3/native/launch-review/
Ionic >= V4: https://ionicframework.com/docs/native/launch-review
It has in app review for ios >10.3 (higher changes to get a review) and simply opens google play market for android.
Dependency injection:
import { LaunchReview } from '#ionic-native/launch-review';
constructor(
private _platform: Platform,
private _launchReview: LaunchReview
) { }
Implementation:
appId = null;
if (this._platform.is('android')) {
appID = '_COM.ANDROID.PACKAGE.NAME_';
} else if (this._platform.is('ios')) {
appID = '_APPLEID_';
}
if (appID) {
if (this._launchReview.isRatingSupported()) {
// For iOS > 10.3
this._launchReview.rating().then((result) => {
alert(result);
});
} else {
this._launchReview.launch(appID);
}
}
2020 Answer. Ionic 4.
Only window.location.assign helped for me. Working both iOS and Android. iOS URL should be itms-apps://itunes.apple.com/app/${iosITunesAppId}, Android one https://play.google.com/store/apps/details?id=${packageName}. packageName can be obtained using cordova-plugin-app-version plugin.
UPD: looks as I found why methods like window.open('market://details?id=com.myapp.something', '_system'); didn't work for me. Looks as they require cordova-plugin-inappbrowser plugin to be installed. I haven't that plugin installed in my app so that method didn't work.
I´m trying to detect if the device is an iPad or an iPhone, but it isn´t working with the emulator. It works if i test it in the safari browser on the iPad. Is there a difference?
It always uses the "else" for iphone..
this i my code:
var isiPad = navigator.userAgent.match(/iPad/i) != null;
$(document).ready(function(){
if(isiPad)
{
window.location.replace("tab/indexTabStart.html");
}
else {
window.location.replace("smart/indexSmartStart.html");
}
});
please help me thanks!
You can try the api provided by phonegap.
try using device.model
device.model - Get the device's model name.
example:
var string = device.model;
Description
The device.model returns the name of the device's model or product. The value is set by the device manufacturer and may be different across versions of the same product.
for full documentation here:
http://docs.phonegap.com/en/3.0.0/cordova_device_device.md.html#Device
(works fine in Chrome on the iPhone)
I get this error:
TypeError: 'undefined' is not an object (evaluating 'win.location') in dg.js line 3
And the lightbox does not open.
The code in question inside PayPal's dg.js is:
startFlow: function (url) {
var win = that._render();
if (win.location) {
win.location = url;
} else {
win.src = url;
}
}
So does mobile Safari not understand that._render()? How do I get around this?
If it matters, I'm using Adaptive Payments, calling it like so:
var dg = new PAYPAL.apps.DGFlow({
trigger: null,
expType: 'light'
});
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
I don't have any problems getting the payKey & the entire payflow works on desktops and in mobile browsers other than Safari (it works on desktop Safari). It also does not work when our site is run as an iOS web app, which I assume is just a shell for Safari anyway.
I can explain why you are seeing this error.
Safari on iOS only allows a window to be opened as a result of a user click/touch event.
The DGFlow._render() function executes:
window.open('', "PPDG");
which returns null if triggered by anything other than a user click/touch event.
I am guessing you are issuing an XMLHttpRequest to generate a PayRequest/PayKey on the server and then in the onsuccess callback you are calling DGFlow.startFlow().
The solution is two split the process into two steps:
When the user is ready to checkout, issue the call to the server to
generate the pay key.
Then, present the user with a button to Checkout with PayPal and when that is clicked, call DGFlow.startFlow()
Found a couple of ways to get around this...location.replace with the PayPal URL or using your own lightbox. I used easybox.
// Replace
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
// with
var RUNNING_AS_WEB_APP = (window.navigator.standalone == true ? true : false);
if (RUNNING_AS_WEB_APP === false) {
dg.startFlow('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
} else {
location.replace('https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey);
// Or, lightbox option:
// $.easybox([{url: 'https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&payKey=' +data.paykey, width: 320, height: 480}]);
}
Try using the mini browser experience where expType=mini. Seems to work better than the lightbox on mobile devices.
Adaptive Payments without modal box or popups?
I tried to create my own app for BlackBerry using BlackBerry workflow SDK and phonegap.
I have a web service which sends html code and I need to use this code in a new window. I tried
window.document.write('test'); But when I use the back button on the phone, the application just quits.
Resolution without html code but url :
//Invoke blackberry browser
var args = new blackberry.invoke.BrowserArguments(url);
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
BlackBerry WebWorks only has one window. You will need to work with that.
So, There are a couple ways you can do what I think you're looking to achieve.
1 - If you just need to show the new html and you dont care about the back button working you can just insert the html into the current page
document.querySelector("body").innerHTML = htmldata;
2 - If you need the back button to will need to save the htmlData to localStorage and change pages, then load the stored html.
localStorage.setItem("htmldata", htmlData);
window.location.href = "page2.html";
document.querySelector("body").innerHTML = localStorage.getItem("htmldata");;
EDIT
3 - Trap hardware key
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, handleBack);
function handleBack() {
alert("handle back button");
}