我正在使用 GCM 向 iOS 应用程序发送远程通知,在前台和后台都收到通知,但在后台通知没有在应用程序图标上显示带有声音和徽章编号的横幅,我应该添加哪些字段以及我应该在哪里添加它们
I tried it and it works great. This is how it works:
Logic works as follows:
Cool Features. GCM for iOS has some cool features as:
UPDATE: It's Google with a capital G now.
If you want to try google sample app. Just pod try Google
.
If you're receiving a remote notification in the background. Likely your content-available = 1
field is already in the json payload, So send your device a local notification and banner to do everything else you want.
let localNotification = UILocalNotification()
localNotification.soundName = UILocalNotificationDefaultSoundName //If you want an alert sound.
localNotification.alertBody = "You received notification" //Put your notification message here
localNotification.applicationIconBadgeNumber += 1 //Change what the badge number should be
UIApplication.sharedApplication().presentLocalNotificationNow(localNotification)
One place to put this code is in a func and call it when you receive the remote notification.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.