how to detect app open from push notification in ionic 3? - ionic-framework

onic Info
Run ionic info from a terminal/cmd prompt and paste the output below.
cli packages: (C:\Users\lenovo\AppData\Roaming\npm\node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.11.2
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : D:\sdk
Misc:
Describe the Bug
Hi i am developing application related to chat. In this application consist of two pages first page consist of list of user contacts and when click on particular contact navigate to the message screen. when user close the app then he/she will receive push notification then i need to navigate the user to message screen but i am unable to do it.
this.fcm.onNotification().subscribe this function is executing after setting root page. so without navigate to root page i want to navigate to message page.
Please help me out to resolve the issue.

try this from my working code.
this.fcm.onNotification().subscribe(data => {
let ref_this = this;
if (data.wasTapped == true) {
ref_this.nav.push('NotificationPage')
console.log("Received in background");
} else {
console.log(data);
ref_this.nav.push('NotificationPage')
console.log("Received in foreground");
}
});

Related

Ionic googleplus plugin: Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'

I am facing this issue when running in browser mode. How can I solve this? Would be possible to open this dialog in a new tab instead of an iFrame?
https://github.com/EddyVerbruggen/cordova-plugin-googleplus
Many thanks for the help!
Using Ionic with following settings:
cordova-plugin-googleplus 5.3.2 "Google SignIn"
Ionic:
ionic (Ionic CLI) : 4.0.5 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0, browser 5.0.4, ios 4.5.5
System:
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Try removing the cordova-plugin-inappbrowser plugin.
Coexist with inAppBrowser plugin (fixed)
Some plugins can only be tested/working inside a device.
I remember that the google+ sign need to use the google play services and the apk signature those things aren't available running in local browser with chrome.
It's likely you test the android push notifications with the chrome it won't work.
For these type of things better if you call the ionic with the live reload to test in the device and reload when you make changes
ionic cordova run android -l -c

ionic pro live deploy download not updating UI

Im working with an ionic app with Ionic Deploy.
I followed the example
async performManualUpdate() {
try {
const haveUpdate = await Pro.deploy.check();
if (haveUpdate){
this.downloadProgress = 0;
await Pro.deploy.download((progress) => {
this.downloadProgress = progress;
})
await Pro.deploy.extract();
await Pro.deploy.redirect();
}
} catch (err) {
}
This works. However, the progress is not updating in view, like it is not "realtime".
Tried to find a workaround but there's no success. Anyone can help me?
Here is my [ionic info]
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.4.0 browser 5.0.1 ios 4.5.4
Ionic Framework : ionic-angular 3.2.1
System:
ios-deploy : 1.9.2
Node : v8.9.1
npm : 5.8.0
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro

Ionic framework How to Return to log in page on platform resume

I have an app that is protected by a log in screen.
I want to show this login screen when the app is resumed, so pause and then re-focussed.
The way the log in screen works is by being the root page and when user successfully authenticates then the root page is set to the home page using
navController.setRoot(view)
This is fine. I then subscribe to platform.resume and set the root again to the log in page.
This works great once. the second time the platform resume is called then the log in page is loaded twice which messes up the log in page.
How can I avoid the page running twice because I have set the root.
I tried looping over the navController entries to remove them all but remove has no effect on the entry list.
I tried popAll() to clear the list then set the root but this did nothing.
Using popToRoot will not work because my root has been set to the home page I now want it to be the log in page.
Any ideas how I can acheive this in a stable manner?
This is my info:
#ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 1.3.7
Cordova Platforms : android 6.3.0 ios 4.4.0
Ionic Framework : ionic-angular 3.5.3
System:
Android SDK Tools : 26.0.2
Node : v6.12.2
npm : 3.10.10
OS : Windows 10
I am posting here as, worryingly, there does not seem to be much action on the ionic forum.
Update - adding the code for resume as requested
platform.resume.subscribe(() => {
this.navCtrl.setRoot(LoginPage, null, {
animate: false
});
});

How can i pass data from an app to another one in ionic 3?

I am working on creating a taxi app , I have two separated apps one for Client and for driver .
I want to send current locations of drivers to clients .I don't know how I can do that .
Firebase is a good option to use as your backend in this situation. It uses web sockets to automatically push data. You can use AngularFire to link Ionic with Firebase. (Video tutorial: https://www.youtube.com/watch?v=I_73tsvj6OI)
Hey #bambo so for your understanding it is not possible to transfer data from one app to another without connection, and in your case both of the app can be in distance where only internet will work. So you can use one of these methods:
APIs for sending the data from one app and receiving it from other app.
Send a notification direct to other app, which contain the data you want to send for ionic you can use PUSH cordova available on
ionic docs.
You can send or receive data through webIntent plugin provided by ionic.
Ionic:
Ionic CLI : 5.0.2 (C:\Windows\System32\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.5
#ionic/app-scripts : 3.2.2
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.0, (and 5 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.5
System:
Android SDK Tools : 26.1.1 (D:\Android\Sdk)
NodeJS : v12.4.0 (D:\node.exe)
npm : 6.9.0
OS : Windows 8.1
Command to install plugin:
ionic cordova plugin add com-darryncampbell-cordova-plugin-intent
npm install --save #ionic-native/web-intent#4
(Add 'Web-Intent' in provider)
Code To receive data:
import { WebIntent } from '#ionic-native/web-intent';
clickMe() {
console.log('clicked')
this.webIntent.getIntent().then((data) => {
console.log('Success', data);
},
err => {
console.log('Error', err);
});
}
Code To send data:
import { WebIntent } from '#ionic-native/web-intent';
sendIntent() {
console.log('sendIntent');
const options = {
action: 'com.example.myapplication',
extras: {
'data': 'Hello Android App'
}
}
this.webIntent.sendBroadcast(options).then((succ) => {
console.log('Success', succ);
},
err => {
console.log('Error', err);
});
}

Getting "Sorry! The configured backend (pro) does not know about ionic upload" When trying to upload the Ionic App

I'm trying to upload the App I built to my Ionic Pro account.
I've linked my account and added the SSH keys but after running ionic upload I'm getting this error
[ERROR] Sorry! The configured backend (pro) does not know about ionic upload.
This is My Ionic Info
cli packages: (/home/jos/Desktop/helloapp/node_modules)
#ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
Gulp CLI : not installed globally
local packages:
Cordova Platforms : android 6.2.3 browser 4.1.0
Ionic Framework : ionic1 1.3.1
System:
Android SDK Tools : 26.0.2
Node : v6.11.0
npm : 3.10.10
OS : Linux 3.13
ionic upload doesn't work with backend pro, you have to create an app
on https://dashboard.ionicjs.com/apps and there will be a setup guide :)