{"__v":4,"_id":"55ee66a073d3941700f760e5","category":{"project":"55e67aaa9cc7c62b00c4a1ea","version":"55e67aab9cc7c62b00c4a1ed","_id":"589b8e1fdbb7cd190026732c","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-02-08T21:31:11.878Z","from_sync":false,"order":6,"slug":"advanced-techniques","title":"Advanced Techniques"},"parentDoc":null,"project":"55e67aaa9cc7c62b00c4a1ea","user":"55d2bd8e2463351700f67dd7","version":{"__v":10,"_id":"55e67aab9cc7c62b00c4a1ed","project":"55e67aaa9cc7c62b00c4a1ea","createdAt":"2015-09-02T04:27:23.612Z","releaseDate":"2015-09-02T04:27:23.612Z","categories":["55e67aac9cc7c62b00c4a1ee","55e67b5556007d23005fee7d","55e67b5dde6fef23009480ca","55e680efde6fef23009480db","55e6829485a9741900314e99","561c61b4ad272c0d00a892df","586c014c0abf1d0f000d04d4","58991d2ad207df0f0002186b","589b8e1fdbb7cd190026732c","58b8ca5e3265d70f001788d4"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-08T04:40:00.143Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":12,"body":"Some third party libraries and frameworks can interfere with the Carnival SDK's ability to collect push tokens and to handle incoming notifications. If devices are registering with Carnival, but without push tokens, you may need to manually forward notifications and device tokens to the Carnival iOS SDK.\n\nTo do this, you will need to override a few delegate methods on your application delegate.\n\nIn `application:didRegisterForRemoteNotificationsWithDeviceToken:` call the `setDeviceTokenInBackground` class method on Carnival:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\\n  // Forward the device token data to the Carnival iOS SDK\\n  [Carnival setDeviceTokenInBackground:deviceToken];\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \" func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {\\n  // Forward the device token data to the Carnival iOS SDK\\n  Carnival.setDeviceTokenInBackground(deviceToken)\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\nTo forward notifications to the Carnival iOS SDK call the `handleNotification:` method on Carnival with the notification received from `application:didReceiveRemoteNotification:` and `applicationDidReceiveRemoteNotification:fetchCompletionHandler:` where appropriate:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\\n  {\\n\\t  // Forward the notification's userInfo to the Carnival iOS SDK\\n\\t  [Carnival handleNotification:userInfo];\\n  }\\n\\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {\\n  // Forward the notification's userInfo to the Carnival iOS SDK\\n  [Carnival handleNotification:userInfo];\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {\\n\\t// Forward the notification's userInfo to the Carnival iOS SDK\\n  Carnival.handleNotification(userInfo)\\n}\\n    \\nfunc application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {\\n\\n\\t// Forward the notification's userInfo to the Carnival iOS SDK\\n  Carnival.handleNotification(userInfo)\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"manually-passing-push-tokens-to-carnival","type":"basic","title":"Manually passing push tokens"}

Manually passing push tokens


Some third party libraries and frameworks can interfere with the Carnival SDK's ability to collect push tokens and to handle incoming notifications. If devices are registering with Carnival, but without push tokens, you may need to manually forward notifications and device tokens to the Carnival iOS SDK. To do this, you will need to override a few delegate methods on your application delegate. In `application:didRegisterForRemoteNotificationsWithDeviceToken:` call the `setDeviceTokenInBackground` class method on Carnival: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\n // Forward the device token data to the Carnival iOS SDK\n [Carnival setDeviceTokenInBackground:deviceToken];\n}", "language": "objectivec" }, { "code": " func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {\n // Forward the device token data to the Carnival iOS SDK\n Carnival.setDeviceTokenInBackground(deviceToken)\n}", "language": "swift" } ] } [/block] To forward notifications to the Carnival iOS SDK call the `handleNotification:` method on Carnival with the notification received from `application:didReceiveRemoteNotification:` and `applicationDidReceiveRemoteNotification:fetchCompletionHandler:` where appropriate: [block:code] { "codes": [ { "code": "- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo\n {\n\t // Forward the notification's userInfo to the Carnival iOS SDK\n\t [Carnival handleNotification:userInfo];\n }\n\n- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {\n // Forward the notification's userInfo to the Carnival iOS SDK\n [Carnival handleNotification:userInfo];\n}", "language": "objectivec" }, { "code": "func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {\n\t// Forward the notification's userInfo to the Carnival iOS SDK\n Carnival.handleNotification(userInfo)\n}\n \nfunc application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {\n\n\t// Forward the notification's userInfo to the Carnival iOS SDK\n Carnival.handleNotification(userInfo)\n}", "language": "swift" } ] } [/block]