你所要求的(像电话一样的格式)在Ionic中是不可能的。但是,您可以将用户重定向到应用程序中的一个视图,在该视图中请求他采取行动。
以推送通知为例。在app.components.ts我初始化此功能时,该平台已准备就绪
initializePushNotifications() {
let pushObject = this.push.init({
android: {
senderID: 'Your ID Here',
icon: 'logo'
},
ios: {
alert: true,
badge: false,
sound: true
},
windows: {}
});
if (!pushObject['error']) {
pushObject.on('registration').subscribe((data: RegistrationEventResponse) => {
// Whatever you want to do
}, err => {
console.log('Couldnt register:', err);
})
pushObject.on('notification').subscribe((data: any) => {
let self = this;
// When the user click the push notification
if (!data.additionalData.foreground) {
switch (data.additionalData.entity_type) {
case 'takeAction':
this.openView(data.additionalData.user_name, data.additionalData.id);
break;
......
}
}
});
pushObject.on('error').subscribe((e: any) => {
console.log(e.message);
});
} else {
console.error(pushObject);
}
}
看,我们在关键additionalData
添加一个对象,你可以通过任何你想要的推消息中。你可以通过entity_type
等值takeAction
。当用户点击它时,您可以打开一个新视图并传递其他参数,如用户名称和实体的ID等。
在此屏幕上,您可以打开一个提醒,要求用户单击“是”或“否”,并根据他的输入发出正确的请求。
注意
我知道这是你问什么,但你的要求不能使用离子满足不同。
你所要求的是不可能的,这不是推送通知所能做到的。 IONIC不能做那样的工作 –
@AhmadAlfy过程就像这样:A向B发送一个要约,而B向B发送一个提示和一个带有Accept/Reject按钮的传入要约页面。 PersonB的应用程序可能无法运行或处于后台模式。如何用离子框架完成此功能?在此先感谢 – 0bj3ct
您可以发送常规推送通知,并在用户打开它时将其重定向到应用程序内部的一个页面,要求他批准或拒绝。 –