When developing with Ionic 2 how does one stay on the current page when making code changes? In Ionic 1 livereload would take you back to your current url - however in ionic 2 there are no urls.
Is there a setting that will make livereload keep me on the current page?
I'm open to enabling URLs as well if that's what it takes to not have to manually navigate back to my page on every code change. However I haven't been able to find how to do that in the v2 docs yet.
To stop live reloading in Ionic2 following changes I have done in the configurations file : ionic.config.js.
In ionic.config.js
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
livereload: [
'www/build/**/*.html',
'www/build/**/*.js',
'www/build/**/*.css'
]
}
above section edited to :
watch: {
sass: ['app/**/*.scss'],
html: ['app/**/*.html'],
}
Then stopped ionic serve by q, and again started. Auto refreshing got stopped, we have to manually refresh to reflect the latest changes.
You could set the this.rootPage in your app.component.ts to the page you are working on. I often do this if i am working on say the foobar.ts page for a while ill change it to
this.rootPage = FooBar;
And then change it back to the default root page when i am done.
Actually ionic.config.js has been deprecated . So i found a way may , go to this node_modules\#ionic\app-scripts\config . Change in file called watch.js
srcFiles: {
paths: ['{{SRC}}/**/*.(ts|html|s(c|a)ss)'],
options: { ignored: ['{{SRC}}/**/*.spec.ts', '{{SRC}}/**/*.e2e.ts', '**/*.DS_Store'] },
callback: watch.buildUpdate
},
No, there is no way to do what you are asking for, because ionic 2 is not using urls. Actually they are handling the pages as a variable on window, so when you or the live reload refresh the page it will go to the initial state. By the way actually there are no plans for implement the angular router, let's wait until the RC, maybe they would like to implement it
Related
I've been developing an app with firebase and stripe payment. I've created a checkout session in stripe and added firebase dynamic links for the success_url and cancel_url. The URLs are working fine. I've tested them outside stripe with a simple html file and it opens the app and takes the user to the correct page. If the page doesn't exist it'll take the user to the assigned website. This is stripe checkout session code:
const session = await stripe.checkout.sessions.create({
line_items: [{
price_data: { currency: 'INR', unit_amount: amount, product_data: { name: 'name' } },
quantity: 1,
}],
mode: 'payment',
success_url: 'https://-------.page.link/payment-success',
cancel_url: 'https://-------.page.link/payment-failed',
payment_intent_data: {
application_fee_amount: fee
},
}, {
stripeAccount: req.query.stripeId,
});
I've changed up the actual link since I don't know how much I'm allowed to share. But I can guarantee the dynamic links works fine. But after payment, the test payment at least, it's suppose to open the app and take the user to a payment success page. AND it was working fine for the first 2 or 3 days. After payment it re-opened the app and took the user to the correct page. But when I tried a few days later, this is what it's taking us to:
Again, I've removed the link since I don't know how much I'm allowed to share. It won't even open the app right now. It just shows this message in the browser. Both success and cancel url are doing the same. Why does the links work outside the function but not in it? Has anyone ever faced any similar issues before? Any help will be greatly appreciated.
It seems like you're trying to open the Checkout Session in a WebView which causing the issue in the redirect. Webviews don't know how to handle an URL Scheme other than http:// or https://. That being said, your problem isn't uncommon and there are multiple ways of solving this.
Your first approach would be to open the Checkout Session in an external browser as described in this answer or try to create your own WebViewClient and override shouldOverrideUrlLoading method like described in this answer. Just note that since the last edit of that answer the signature of the shouldOverrideUrlLoading method has changed but the logic should still be used the same way but instead of dealing with the String url, you will have to deal with a WebResourceRequest.
Had the same issue. I solved it by changing the mode like following:
await launchUrl(
url,
mode: LaunchMode.externalApplication, // Add this line
)
url_launcher version => 6.1.7
I am working with ionic application, ionic CLi 4.5.0
I am using using ionic serve & open preview in browser & when edit any file live reload load to root page but I need to load last woreking/loaded page
suppose root page is home so liveload always load at http://localhost:8100/#/home
if my last working/open page is http://localhost:8100/#/login and I make change in any file liveload still load at http://localhost:8100/#/home but I need to load at http://localhost:8100/#/login
It will always load the rootpage which you configured in your app.compontent.ts. If it is text change, it will do a hot-reload feature. If you make any changes in your component, it will restart from the root page.
The simple way to do is to store the session in observable object or session storage after successful login.
ionViewDidEnter() {
this.storage.get(LOCALSTORAGE.TOKEN).then((val) => {
if (val)
this.navCtrl.setRoot(HomePage);
});
}
Using an observable object,
private tokenString: BehaviorSubject<string>;
setTokenObject(val) {
if (val)
this.tokenString.next(val);
else
console.log(val);
}
getTokenObject() {
return this.tokenString.asObservable();
}
Updating the token in login success for the first time
this.tokenString.next(token); // here token should read it from your login response
Hope this helps!
I'm trying to get working Push Notifications on my FirefoxOS App. While it's working as expecte when the app is opened, when the app is closed it not works anymore. I thought that was the app is trying to execute the whole app instead only the handler so I'm trying to use the messages section on the manifest.webapp.
"messages": [
{ "push": "/push/push.html" },
{ "push-register" : "index.html" },
{ "notification": "index.html" }
],
My code on /push/push.html is:
<script>
navigator.mozSetMessageHandler('push', function () {
c = new Notification( 'testing 4' );
});
</script>
But it seems that's not loading the file when the push message arrives the device. For me, it doesn't seems to be a path problem, because I tried everything (launch path is /index.html, and I've tried moving push.html to the root and put /push.html).
Any clue?
Well, after hours trying it and a lot of research, seems that's not possible to get working the push in another page.
Remember: when a user selects an app, the lauch_path is displayed.
There’s a bug right now that restricts push notifications to the page
that calls register(). Right now, what’s under “messages” doesn’t
matter if it’s not the same as the page that calls register(). Keep
your eye on that bug if you want to know when it’s fixed. For now,
it’s probably a good idea to keep your app to one page and use dynamic
formatting to present info back to the user.
Firefox OS v1.1 only allows the page that registers for Push
Notifications to recieve them, so you cannot have / call
navigator.push.register() and have /push.html be the receiver that
uses navigator.mozSetMessageHandler().
More info about the bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=800431 [^]
https://bugzilla.mozilla.org/show_bug.cgi?id=897112 [^]
i've a requirement as below after use logs-in:
- user will first see a nda agreement page, where he has to sign on it and submit
- then after sumit, it has to load shell and then he cont with other screens in shell
the key here is, if any time the user refreshes the screen.. it should always takes him to shell and not the the nda screen. as we've to remember the user's decision and load only shell.
-wt is the best way to handle this?
-i hope (prefer) to do this in the same ui5 project only.. rather than 2 different projs.
-how do we remember the user's decision? its a kind of session handling within ui5!
-do we've to use content.plastAt() from nda page to shell? how to achieve this..!
You can do the following in a few ways, lets tackle the NDA remember feature.
You can use javascript's session storage api for example, this will make sure that a refresh will keep the value but a completely new session will show the NDA again.
Now if you want Ui5 based solution for the NDA you can set the first screen as the NDA and in the submit button to navigate to the next page and detach the NDA page from the shell.
Another way to achieve this is by using a modal popup with the NDA and on click just remove the popup
and save the data in the session storage.
Hope this gave you a clear idea.
BR,
Saar
you need to use Session Storage to meet your requirement
In the NDA sign on page check sessionStorage data and in the controller of NDA write this code
onInit: function() {
var oView = this.getView();
oView.addEventDelegate({
onBeforeShow : jQuery.proxy(function(evt) {
this.onBeforeShow();
}, this)
});
},
onBeforeShow: function(){
if(SessionStorage['UserName'])
{
sap.ui.getCore().getEventBus().publish("nav", "to", {
id : "idShell",//id to navigate to shell Page
data : {}
});
}
else
{
// DO SOMTHING
}
}
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);
}
);