如何从AWS SNS发送推送通知时自动增加徽章编号?

时间:2016-05-01 15:01:00

标签: ios swift amazon-web-services

我正在使用Amazon Web Services将“推送通知”发送到IOS应用程序。如何在swift 2中自动增加徽章编号?

我在AppDelegate中使用以下代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {


    let notificationTypes : UIUserNotificationType = [.Alert, .Badge, .Sound]
    let notificationSettings : UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
    UIApplication.sharedApplication().registerForRemoteNotifications()

    UIApplication.sharedApplication().applicationIconBadgeNumber = 0        
    return true
    }

1 个答案:

答案 0 :(得分:0)

你不能只说'#34;增加徽章数"。

它的工作方式是您必须告知您明确发送的每个推送通知中的徽章计数。