Issue
Hi I am using Ionic 5 with Angular. I have a mobile app that I am currently developing a Web App for that uses the same codebase as the mobile app.
I'm looking for a way to configure some environment variables to recognise if the app is deployed on Mobile App or Web App. Thanks :)
Solution
import {Platform } from '@ionic/angular';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
if (this.platform.is('android')) {
console.log("running on Android device!");
}
if (this.platform.is('ios')) {
console.log("running on iOS device!");
}
if (this.platform.is('mobileweb')) {
console.log("running in a browser on mobile!");
}
});
}
}
Answered By - Kinglish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.