使用以下代码创建了配置文件,但是当我尝试运行开发测试时,我得到了llbd和app崩溃。
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
-> Bool {
// Override point for customization after application launch.
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert
| UIUserNotificationType.Sound
var setting = UIUserNotificationSettings(forTypes: type, categories:
nil)
UIApplication.sharedApplication().registerUserNotificationSettings(setting)
UIApplication.sharedApplication().registerForRemoteNotifications()
return true
}
func application(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
println(deviceToken)
}
func application(application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: NSError) {
println(error)
}
能够按照LastMove的洞察力显示Push弹出窗口。但我连接到Push网络时出错。在第一次测试时我收到了
Trying 17.172.232.45...
Connected to gateway.sandbox.push-apple.com.akadns.net
但是当我试图运行php时我得到了
Failed to connect: 111 Connection refused
在终端测试中我也看到了:
openssl s_client -connect gateway.sandbox.push.apple.com:2195
CONNECTED(00000003)
depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated
by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification
Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0
6236:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake
failure:/SourceCache/OpenSSL098
/OpeJamesJaJamJJJJJJJJJJJJJJaJamJamesJamesJameJamJaJJJJaJaJamess-MacBoJamJa
答案 0 :(得分:1)
我认为您的问题与iOS 7/8有关。 您用于推送通知的API是新的。 它不兼容iOS 7。 如果你需要针对iOS 7使用旧时尚。 或更好: https://stackoverflow.com/a/28742391/2327367
// Register for Push Notitications, if running iOS 8
if application.respondsToSelector("registerUserNotificationSettings:") {
let types:UIUserNotificationType = (.Alert | .Badge | .Sound)
let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
} else {
// Register for Push Notifications before iOS 8
application.registerForRemoteNotificationTypes(.Alert | .Badge | .Sound)
}