How to send parameters to a tab in ionic 3 - ionic-framework

im building a application in ionic 3 witch i wont to send data to a tab
i'm following this documentation:
https://ionicframework.com/docs/api/components/tabs/Tabs/
this is an example of what a want:
ionViewDidEnter() {
this.tabRef.select(2, {one, "1"});
}
thanks

Related

How can I programatically close an ionic app?

I've tried the two following approaches to close my ionic app but non has worked.
1.
closeApp(){
this.platform.backButton.subscribeWithPriority(999999, () => {
navigator['app'].exitApp();
})
}
In this approach, when I click on the back button, the app is disappeared, but it's in the list of the background running apps. This doesn't help me, because I need the app to be completely closed and the user be forced to reopen the app by clicking on its icon.
2.
closeApp(){
const { App } = Plugins;
App['exitApp'];
}
in this case, nothing happens, i.e., I stay on the page.
Is there any other approach or plugin which I can use?
I am working with capacitor: 3 and testing on android 12.
import { App } from '#capacitor/app';
ExitApp() {
App.exitApp();
}
try this

How can I close an Ionic 5 app from code?

I can't find the way to close an app in Ionic 5 system. Looks like the way to do it in Ionic 4 is not working for Ionic 5.
Is it possible to do?
closeApp() {
this.platform.backButton.subscribeWithPriority(999999, () => {
navigator['app'].exitApp();
// or trigger any action you want to achieve
}) //Amended missing a closing bracket
}

How to disable Android back button in ionic 3 pwa app

I am working on progressive web app with ionic 3 and angular 6 framework.
Every thing works fine but when I press my browser back button or mobile back button my application get closed.
I tried to search how to do this, I am able to disable browser back button with java script but on mobile app it's not working.
<script>
// window.onbeforeunload = function() { return "Your work will be lost.";
};
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
}, 100);
</script>
I tried to register the back button event and lot's more but none of that is worked fine for me.
Can anyone have same issue then please tell me how to resolve this.
Thanks,
Dattatray
You can use Ionic's Platform to override the physical back button on Android.
Add it into app.component.ts file as such :
import { Platform } from 'ionic-angular';
constructor(public plt: Platform) {}
platform.registerBackButtonAction(() => {
//Add your code here
},100);
Ionic Platform Service.

How to remove Tabs feature

I've started my app using ionic start myApp tabs.
Now, I'd like to totally remove tabs from the app.
I tried changing startpage but it doesn't work...
Is there some kind of feature like ionic generate remove... ?
Thanks
You can't automatically remove pages with ionic CLI,
However, you can start a blank project with
ionic start myApp2 blank

How to detect view changes automatically in Ionic 2

I have a use case where I need to detect current view being shown to the user to report to Google Analytics. I am aware of Ionic 2's View Lifecycle hooks but that is not what I am after.
What would like to know if there is a way to 'hook' into ionic's navigation system to subscribe to navigation events and get route or view object every time user navigates the app. Since Ionic 2 is not using Angular2's Router I can't use following:
export class AppComponent {
private currentRoute:string;
constructor(_router:Router,
_location:Location) {
_router.events.subscribe((event:Event) => {
if (event instanceof NavigationEnd) {
// When the route is '/', location.path actually returns ''.
let newRoute = this._location.path() || '/';
// If the route has changed, send the new route to analytics.
if (this.currentRoute != newRoute) {
ga('send', 'pageview', newRoute);
this.currentRoute = newRoute;
}
}
});
}
}
Does anyone know how to subscribe to navigation changes in Ionic 2 app?
My current setup as of time of wrighting is:
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.48
You can subscribe to App Lifecycle events which are described in the docs
To be more specific, you need to inject App from ionic-angular and then add code like this where needed:
this.app.viewWillEnter.subscribe(viewCtrl => {
console.log('Entering new view')
console.log(viewCtrl)
})