我只是想看看我的令牌设备。
这就是我的所作所为:
while($table = mysqli_fetch_array($result)) {
echo '<a href="yourPath/'. $student_courses[0] . '">' .
$student_courses[0] . '</a>';
}
但是func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let pushSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes:[UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound],categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(pushSettings)
UIApplication.sharedApplication().registerForRemoteNotifications()
return true
}
// Successfully registered for push
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let trimEnds = deviceToken.description.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: "<>"))
let cleanToken = trimEnds.stringByReplacingOccurrencesOfString(" ", withString: "", options: []); print(cleanToken)
//registerTokenOnServer(cleanToken) //theoretical method! Needs your own implementation
}
// Failed to register for Push
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
NSLog("Failed to get token; error: %@", error) //Log an error for debugging purposes, user doesn't need to know
}
什么也没做。我不知道我是否可以在AppDelegate中使用print(cleanToken)
。我还创建了一个全局变量,并将print
保存到该新变量中。然后我在我的viewController中打印它,但它是空的。
答案 0 :(得分:1)
你是否可以在模拟器中运行它?然后你可能不会在didRegisterForRemoteNotificationsWithDeviceToken
接到电话。你需要在实际的手机上运行它
答案 1 :(得分:0)
固定。我只是通知我的应用程序停用了sos代码不起作用。我已经卸载了应用程序并再次安装它,因此它运行正常。