[英]IOS push notification issue on appcelerator
i have a big problem on my IOS app. 我的IOS应用程序有个大问题。 I follow the guide provide by appcelerator documentation to setup my iOS push notification. 我遵循appcelerator文档提供的指南来设置我的iOS推送通知。 All seemed work fine, on my appcelerator dashboard i see under the device section my device registered with its token, and when i send a push notification on the detail's push (in push notification log) i read my id device number with a perfect Success(1). 一切似乎都很好,在我的加速器仪表板上,我在设备部分下看到我的设备已使用其令牌注册,并且当我在详细信息的推送中发送推送通知时(在推送通知日志中),我读到了ID设备编号,并获得了完美的成功( 1)。
But on my device i didn't receive any notification. 但是在我的设备上,我没有收到任何通知。 I tried with my app opened and with my app closed, but nothing has showed. 我尝试打开我的应用程序,然后关闭我的应用程序,但没有任何反应。 I don't know why this happen. 我不知道为什么会这样。 On my android all work fine. 在我的android上一切正常。 Here my code: 这是我的代码:
//PUSH NOTIFICATION
var Cloud = require("ti.cloud");
//controllo se ho un token
var deviceToken = Ti.App.Properties.getString("deviceToken");
if ( deviceToken == "" || deviceToken == null) {
requireToken();
} else {
if ( Ti.App.Properties.getString("subscribed") !== "true" ) {
subscribeToChannel(deviceToken);
}
}
//chiedo un token
function requireToken() {
// Check if the device is running iOS 8 or later
if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
Ti.API.warn( "entrato nella versione" )
// Wait for user settings to be registered before registering for push notifications
Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
// Remove event listener once registered for push notifications
Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);
Ti.Network.registerForPushNotifications({
success: deviceTokenSuccess,
error: deviceTokenError,
callback: receivePush
});
});
// Register notification types to use
Ti.App.iOS.registerUserNotificationSettings({
types: [
Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
]
});
}
// For iOS 7 and earlier
else {
Ti.Network.registerForPushNotifications({
// Specifies which notifications to receive
types: [
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_SOUND
],
success: deviceTokenSuccess,
error: deviceTokenError,
callback: receivePush
});
}
function deviceTokenSuccess(e) {
Ti.API.warn( "token ricevuto" )
Ti.App.Properties.setString("deviceToken", e.deviceToken);
subscribeToChannel(e.deviceToken);
}
function deviceTokenError(e) {
//error action
}
}
//controllo se sono iscritto alle notifiche push
if ( Ti.App.Properties.getString("subscribed") !== "true" ) {
subscribeToChannel(deviceToken);
}
function subscribeToChannel (_deviceToken) {
Ti.API.warn( "subscribe fatta" )
Cloud.PushNotifications.subscribeToken({
device_token: _deviceToken,
channel: "ios_alerts",
type: Ti.Platform.name == 'android' ? 'android' : 'ios'
}, function (e) {
if (e.success) {
Ti.App.Properties.setString("subscribed", "true");
}
});
};
function receivePush(e) {
Ti.API.warn("alert ricevuto" + JSON.stringify(e) )
alert(e)
}
is probably something related to your certificates on Apple panel. 可能与您在Apple面板上的证书有关。 Check if you enabled APS with your appid and if not, activate it, then generate another provisioning profiles and re-build the app. 检查是否使用您的appid启用了APS,如果没有启用,请激活它,然后生成另一个配置文件并重新构建该应用程序。 You will also have to put a .p12 file in the Appcelerator platform website. 您还必须在Appcelerator平台网站上放置一个.p12文件。
Just in case this is your issue(s): 以防万一这是您的问题:
Chris 克里斯
Ref: https://archive.appcelerator.com/question/148135/no-reply-from-tinetworkregisterforpushnotifications 参考: https : //archive.appcelerator.com/question/148135/no-reply-from-tinetworkregisterforpushnotifications
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.