【发布时间】:2017-01-19 03:02:47
【问题描述】:
我对使用钛合金 appcelerator 推送 iOS 感到非常头疼。
我在testflight中生成了几个版本,但没有一个出现在iOS通知中心,但是,当我直接刷入设备时,它在我的iPad Mini上可以正常工作。
我目前正在使用这些设置:
Operating System
Name = Mac OS X
Version = 10.12
Architecture = 64bit
# CPUs = 4
Memory = 4294967296
Node.js
Node.js Version = 4.6.0
npm Version = 2.15.9
Titanium CLI
CLI Version = 5.0.9
Titanium SDK
SDK Version = 5.5.1.GA
SDK Path = /Users/silvio/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA
Target Platform = iphone
Xcode 版本:8.2 (8C38)
我在 Alloy.js 中的代码:
if (Ti.Platform.name === 'android') {
// set android-only options
var pnOptions = {
senderId: 'xxxx', // It's the same as your project id
notificationSettings: {
sound: 'mysound.mp3', // Place soudn file in platform/android/res/raw/mysound.mp3
smallIcon: 'appicon.png', // Place icon in platform/android/res/drawable/notification_icon.png
largeIcon: 'appicon.png', // Same
vibrate: true, // Whether the phone should vibrate
insistent: true, // Whether the notification should be insistent
group: 'Edufy', // Name of group to group similar notifications together
localOnly: false, // Whether this notification should be bridged to other devices
priority: 2 // Notification priority, from -2 to 2
}
};
} else { // set ios-only options.
// Sets interactive notifications as well if iOS8 and above. Interactive notifications is optional.
if (parseInt(Ti.Platform.version.split(".")[0], 10) >= 8) {
var thumbUpAction = Ti.App.iOS.createUserNotificationAction({
identifier: "THUMBUP_IDENTIFIER",
title: "Aceitar",
activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive: false,
authenticationRequired: false
});
var thumbDownAction = Ti.App.iOS.createUserNotificationAction({
identifier: "THUMBDOWN_IDENTIFIER",
title: "Regeitar",
activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive: false,
authenticationRequired: false
});
var thumbUpDownCategory = Ti.App.iOS.createUserNotificationCategory({
identifier: "THUMBUPDOWN_CATEGORY",
// The following actions will be displayed for an alert dialog
actionsForDefaultContext: [thumbUpAction, thumbDownAction],
// The following actions will be displayed for all other notifications
actionsForMinimalContext: [thumbUpAction, thumbDownAction]
});
var pnOptions = {
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND],
categories: [thumbUpDownCategory]
};
} else { //No support for interactive notifications, omit categories
var pnOptions = {
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND]
};
}
}
// set cross-platform event
var onReceive = function(event) {};
// Create instance with base url
var tiPush = require('ti-push-notification').init({
backendUrl: "http://xxxx.com.br/painel/ws/push_test.php"
});
// register this device
tiPush.registerDevice({
pnOptions: pnOptions,
onReceive: onReceive,
extraOptions: {
action: 'register',
user_id: 123
}
});
我在苹果商店的证书都是有效的,如下图所示:
启用推送通知:
证书:
省概况:
另外,我尝试在这些位置添加 Entitlements.plist:
- 项目/权利.plist
- 项目/应用程序/Entitlements.plist
- 项目/app/平台/ios/Entitlements.plist
- 项目/app/平台/ios/.plist
我还将标记内的行添加到 tiapp.xml,但它不起作用......在 Entitlements.plist 代码下方:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string> <!-- Either development or production -->
<key>application-identifier</key>
<string>xxxx.com.colegiokennedy</string>
<key>keychain-access-groups</key>
<array>
<string>xxx.com.colegiokennedy</string>
</array>
</dict>
</plist>
我也尝试过将开发环境更改为生产环境,但也没有成功。
【问题讨论】:
-
你解决过这个问题吗?
标签: ios xcode apple-push-notifications titanium appcelerator