{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Badge Number Delegate","type":"basic","slug":"pulsate-badge-number-delegate-1","excerpt":"","body":"Pulsate allows you to get callbacks every time a badge number update happens. All you need to do is implement the PULPulsateBadgeDelegate.\n\nExample Usage with Objective-C:\nIn your AppDelegate.h add the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \":::at:::interface AppDelegate : UIResponder <UIApplicationDelegate, PULPulsateBadgeDelegate>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nIn your AppDelegate.m\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)badgeUpdated:(NSInteger)badgeNumber {\\n\\n}\\n\\n-(void) badgeDecrementBy:(NSInteger)badgeDecrement totalCount:(NSInteger)badgeNumber {\\n    \\n}\\n\\n-(void) badgeIncrementBy:(NSInteger)badgeIncrement totalCount:(NSInteger)badgeNumber {\\n    \\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nAlso in your AppDelegate in the *didFinishLaunchingWithOptions* method add the following code\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \" (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\\n    PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\\n    manager.badgeDelegate = self;\\n    return YES;\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nExample usage in Swift:\nIn your AppDelegate.swift\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import UIKit\\nimport CoreData\\nimport PULPulsate\\n\\[email protected]\\nclass AppDelegate: UIResponder, UIApplicationDelegate, PULPulsateBadgeDelegate {\\n\\t\\n  var window: UIWindow?\\n    \\n  func badgeUpdated(_ badgeNumber: Int) {\\n  }\\n    \\n  func badgeDecrement(by badgeDecrement: Int, totalCount badgeNumber: Int) {\\n  }\\n    \\n  func badgeIncrement(by badgeIncrement: Int, totalCount badgeNumber: Int) {\\n  }\\n    \\n  \\n  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool \\n  {\\n      do {\\n          let authData: PULAuthorizationData = try PULAuthorizationData(appId: \\\"APP_ID\\\", andAppKey: \\\"APP_KEY\\\")\\n            \\n          let pulsateManager = try PULPulsateFactory.getInstanceWith(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions)\\n          pulsateManager.badgeDelegate = self;           \\n      } catch {\\n          print(error)\\n      }\\n\\n      return true\\n    }\\n}\\n\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","updates":[],"order":3,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5f44d67df34c9603b05ed2f5","createdAt":"2020-08-25T09:14:37.518Z","user":"57bc3654b9c7f0220009c77b","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"SDK Advanced","slug":"sdk-advanced","order":3,"from_sync":false,"reference":false,"_id":"5f44d209703f05006a2a4fa9","createdAt":"2020-08-25T08:55:37.604Z","version":"5e5013741b3b20006532951d","project":"54aa7f773b56130b0056c86e","__v":0},"version":{"version":"2.7","version_clean":"2.7.0","codename":"iOS SDK","is_stable":false,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5e5013741b3b200065329486","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","5e5013741b3b200065329487","5e5013741b3b200065329488","5e5013741b3b200065329489","5e5013741b3b20006532948a","5e5013741b3b20006532948b","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","5e5013741b3b20006532948c","5e5013741b3b20006532948d","5c73dd27e8fdc000572a206a","5e5013741b3b20006532948e","5e53d9a2f75c0b0020de8935","5f44d1fbd1c58d040fdf03ba","5f44d202a2e3eb02b1c4c806","5f44d209703f05006a2a4fa9","5f44d210b1ba9f004200b689"],"_id":"5e5013741b3b20006532951d","project":"54aa7f773b56130b0056c86e","forked_from":"5e4fbbbda8fb41028f1861fe","__v":5,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z"},"project":"54aa7f773b56130b0056c86e","__v":0,"parentDoc":null}

Badge Number Delegate


Pulsate allows you to get callbacks every time a badge number update happens. All you need to do is implement the PULPulsateBadgeDelegate. Example Usage with Objective-C: In your AppDelegate.h add the following code [block:code] { "codes": [ { "code": "@interface AppDelegate : UIResponder <UIApplicationDelegate, PULPulsateBadgeDelegate>", "language": "objectivec" } ] } [/block] In your AppDelegate.m [block:code] { "codes": [ { "code": "- (void)badgeUpdated:(NSInteger)badgeNumber {\n\n}\n\n-(void) badgeDecrementBy:(NSInteger)badgeDecrement totalCount:(NSInteger)badgeNumber {\n \n}\n\n-(void) badgeIncrementBy:(NSInteger)badgeIncrement totalCount:(NSInteger)badgeNumber {\n \n}", "language": "objectivec" } ] } [/block] Also in your AppDelegate in the *didFinishLaunchingWithOptions* method add the following code [block:code] { "codes": [ { "code": " (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n PULPulsateManager* manager = [PULPulsateFactory getDefaultInstance];\n manager.badgeDelegate = self;\n return YES;\n}", "language": "objectivec" } ] } [/block] Example usage in Swift: In your AppDelegate.swift [block:code] { "codes": [ { "code": "import UIKit\nimport CoreData\nimport PULPulsate\n\[email protected]\nclass AppDelegate: UIResponder, UIApplicationDelegate, PULPulsateBadgeDelegate {\n\t\n var window: UIWindow?\n \n func badgeUpdated(_ badgeNumber: Int) {\n }\n \n func badgeDecrement(by badgeDecrement: Int, totalCount badgeNumber: Int) {\n }\n \n func badgeIncrement(by badgeIncrement: Int, totalCount badgeNumber: Int) {\n }\n \n \n func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool \n {\n do {\n let authData: PULAuthorizationData = try PULAuthorizationData(appId: \"APP_ID\", andAppKey: \"APP_KEY\")\n \n let pulsateManager = try PULPulsateFactory.getInstanceWith(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions)\n pulsateManager.badgeDelegate = self; \n } catch {\n print(error)\n }\n\n return true\n }\n}\n", "language": "text" } ] } [/block]