如何使用 ionic 获取 IOS 设备令牌?
How to fetch IOS device token using ionic?
离子版本 2.0
科尔多瓦版本 6.3.1
Xcode8
已经尝试过这两个链接,但没有帮助。
http://ngcordova.com/docs/plugins/pushNotifications/
https://github.com/hollyschinsky/PushNotificationSample
正在寻找详细的 tutorial/material 以使用 ionic 获取 IOS 的设备令牌。
你必须使用这个plugin
if ( device.platform == 'iOS'){
pushNotification.register(
tokenHandler,
errorHandler,
{
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN"
});
}
}
在设备就绪事件后写入。
function errorHandler(error) {
alert(error);
}
这是错误回调函数。
function tokenHandler(result){
// Your iOS push server needs to know the token before it can push to this device
// here is where you might want to send it the token for later use.
//alert('device token = ' + result);
sDeviceId = result ;
}
在 sDeviceId 中,您可以获得设备令牌。
http://ngcordova.com/docs/plugins/pushNotifications/
只尝试这个
我也遇到了同样的问题
请检查IOS OS版本的测试设备。如果是10.0以上请做
适当更改功能部分的Xcode设置
允许推送通知(应选中)。
PFB:
要使用 Ionic 推送通知,您必须发布最新的 Ionic 版本,即 Ionic 版本 2,如果您使用的是旧版本(低于 Ionic 版本 1),它将无法工作。
CordovaPush、CordovaPush v5 已被弃用,因此不要使用它们。
要详细了解 Ionic 2 中的推送通知,请参阅此 ionic 2 push
离子版本 2.0 科尔多瓦版本 6.3.1 Xcode8
已经尝试过这两个链接,但没有帮助。
http://ngcordova.com/docs/plugins/pushNotifications/
https://github.com/hollyschinsky/PushNotificationSample
正在寻找详细的 tutorial/material 以使用 ionic 获取 IOS 的设备令牌。
你必须使用这个plugin
if ( device.platform == 'iOS'){
pushNotification.register(
tokenHandler,
errorHandler,
{
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN"
});
}
}
在设备就绪事件后写入。
function errorHandler(error) {
alert(error);
}
这是错误回调函数。
function tokenHandler(result){
// Your iOS push server needs to know the token before it can push to this device
// here is where you might want to send it the token for later use.
//alert('device token = ' + result);
sDeviceId = result ;
}
在 sDeviceId 中,您可以获得设备令牌。
http://ngcordova.com/docs/plugins/pushNotifications/
只尝试这个
我也遇到了同样的问题
请检查IOS OS版本的测试设备。如果是10.0以上请做
适当更改功能部分的Xcode设置
允许推送通知(应选中)。
PFB:
要使用 Ionic 推送通知,您必须发布最新的 Ionic 版本,即 Ionic 版本 2,如果您使用的是旧版本(低于 Ionic 版本 1),它将无法工作。
CordovaPush、CordovaPush v5 已被弃用,因此不要使用它们。
要详细了解 Ionic 2 中的推送通知,请参阅此 ionic 2 push