我想通过PHP脚本向所有应用用户发送推送通知。关于Google遗憾的是,没有关于Swift推送通知的教程。 Parse.com我不想用。有人可以帮帮我吗?
答案 0 :(得分:3)
现在好了! (:
为APN创建证书: raywenderlich.com
Swift Code:
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)
}
在Xcode控制台中找到deviceToken
PHP脚本
从这里使用PHP脚本raywenderlich.com(向下滚动)
运行PHP脚本和中提琴(: