How to test a Push Pre-Permissions message
If you simply want to test the appearance of a custom Push Pre-Permissions template, then the easiest way (without altering the code of the custom Push Pre-Permissions) is to preview the message on a registered developer’s device.
If there are multiple registered developer’s devices, as well as multiple builds, then it may make sense to alter the templates of the push pre-permission message to properly QA the Push Pre-Permissions. Altering the templates may be necessary if your team has multiple registered developer’s devices, as the preview will go to all registered developer devices.
Normally, with Push Pre-Permissions, the code under withResponder
calls for the registration (or opt out) of the device for push notifications. Currently, we recommend that you alter the Push Pre-Permissions to display as a center popup for testing. Within the custom templates, under withResponder:^BOOL(LPActionContext *context){
, copy the following code:
[Leanplum onceVariablesChangedAndNoDownloadsPending:^{ @try {
[self closePopup:NO withAcceptAction:NO]; [self>_contexts addObject:context];
[self showPopup];
}
@catch (NSException *exception) {
LOG_LP_MESSAGE_EXCEPTION; }
}];
return YES; }];
Then, make the code modifications to ensure that the Push Pre-Permissions renders properly within the app. Using this method, you can target a specific device without disrupting other developers.
Note: Make sure that once you are ready to push this specific campaign to production that you replace withResponder with the correct code to obtain the push tokens for the devices.
The importance of resetting your device’s push settings
When testing Push Pre-Permissions for appearance and functionality, it is important to reset your device’s push notification settings after each time you opt in or out of the system-level prompt. There are two options: resetting the push settings, and resetting the device. The former is simpler and therefore preferable.
Resetting push settings
- Delete your app from the device.
- Reinstall your app and open it.
Now, you should be prompted for the Push Pre-Permissions as intended.
Resetting the device
- Go to Settings > General > Reset > Reset all Contents and Settings (the device will now effectively be restored to factory settings).
- Reinstall your app, open it and test the push pre-permissions messsage.
iOS will treat this as a new device and will therefore display the Push Pre-Permissions.
Updated about 4 years ago