PhoneGap 푸시 알림 플러그인을 통합했습니다. Android에서 알림을받을 수 있으며 앱이 포 그라운드에있을 때 특정 페이지를 열 수 있습니다. 앱이 백그라운드에있는 동안 사용자가 알림을 클릭하면 특정 페이지를 열어보고 싶지만 어떤 해결책도 찾을 수 없습니다. 나는 아래 링크를 시도했다. 이 같은 여기 앱이 배경에있는 동안 Ionic 3에서 푸시 알림을 클릭하면 특정 페이지를 여는 방법은 무엇입니까?
https://medium.com/@ankushaggarwal/push-notifications-in-ionic-2-658461108c59
내 코드입니다initPushNotification() {
if (!this.platform.is('cordova')) {
console.warn('Push notifications not initialized. Cordova is not available - Run in physical device');
return;
}
const options: PushOptions = {
android: {
senderID: 'YOUR_SENDER_ID'
},
ios: {
alert: 'true',
badge: false,
sound: 'true'
},
windows: {}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('registration').subscribe((data: any) => {
console.log('device token -> ' + data.registrationId);
//TODO - send device token to server
});
pushObject.on('notification').subscribe((data: any) => {
console.log('message -> ' + data.message);
//if user using app and push notification comes
if (data.additionalData.foreground) {
// if application open, show popup
let confirmAlert = this.alertCtrl.create({
title: 'New Notification',
message: data.message,
buttons: [{
text: 'Ignore',
role: 'cancel'
}, {
text: 'View',
handler:() => {
//TODO: Your logic here
this.nav.push(DetailsPage, { message: data.message });
}
}]
});
confirmAlert.present();
} else {
//if user NOT using app and push notification comes
//TODO: Your logic on click of push notification directly
this.nav.push(DetailsPage, { message: data.message });
console.log('Push notification clicked');
}
});
pushObject.on('error').subscribe(error => console.error('Error with Push plugin' + error));
}
나는 또한 동일한 문제에 직면하고 있습니까? 어떻게 고쳐? – Kittu