{"__v":1,"_id":"56a2692f6928550d006c8327","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":"2016-01-22T17:38:55.338Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"# 1. Delaying the push prompt\n\nIf you would like to delay prompting for push notifications until later in the app (which is recommended from a usability perspective), then you can do something like the following.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Call startEngine and pass in NO for registerForPushNotifications\\n[Carnival startEngine:APP_KEY registerForPushNotifications:NO];\\n\\n// Ensure that push notifications are requested *IF* the user has accepted this in the past\\nif ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {\\n    // Register for push notifications in this block      \\n\\t\\t// Apple recommends to request a new push token every launch\\n\\t\\t// https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW14\\n}\",\n      \"language\": \"objectivec\",\n      \"name\": \"Objective C - didFinishLaunching\"\n    }\n  ]\n}\n[/block]\n# 2. Requesting push permission from the user\n\nWhen you are ready to ask the user for push permission (i.e. as part of an on-boarding sequence), you will need to use Apple's Notification APIs directly.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// When you are ready to prompt your users for push notifiations:\\n// On iOS7, note: this method will prompt the user for push notification permissions\\n\\t[[UIApplication sharedApplication] registerForRemoteNotificationTypes:NOTIFICATION_TYPES]\\n\\n// On iOS8\\n\\tUIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:NOTIFICATION_TYPES categories:nil]; \\n[[UIApplication sharedApplication] registerUserNotificationSettings:settings];\\n[[UIApplication sharedApplication] registerForRemoteNotifications];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"delaying-the-push-prompt","type":"basic","title":"Delaying the push prompt (iOS)"}

Delaying the push prompt (iOS)


# 1. Delaying the push prompt If you would like to delay prompting for push notifications until later in the app (which is recommended from a usability perspective), then you can do something like the following. [block:code] { "codes": [ { "code": "// Call startEngine and pass in NO for registerForPushNotifications\n[Carnival startEngine:APP_KEY registerForPushNotifications:NO];\n\n// Ensure that push notifications are requested *IF* the user has accepted this in the past\nif ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {\n // Register for push notifications in this block \n\t\t// Apple recommends to request a new push token every launch\n\t\t// https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW14\n}", "language": "objectivec", "name": "Objective C - didFinishLaunching" } ] } [/block] # 2. Requesting push permission from the user When you are ready to ask the user for push permission (i.e. as part of an on-boarding sequence), you will need to use Apple's Notification APIs directly. [block:code] { "codes": [ { "code": "// When you are ready to prompt your users for push notifiations:\n// On iOS7, note: this method will prompt the user for push notification permissions\n\t[[UIApplication sharedApplication] registerForRemoteNotificationTypes:NOTIFICATION_TYPES]\n\n// On iOS8\n\tUIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:NOTIFICATION_TYPES categories:nil]; \n[[UIApplication sharedApplication] registerUserNotificationSettings:settings];\n[[UIApplication sharedApplication] registerForRemoteNotifications];", "language": "objectivec" } ] } [/block]