Apple and FCM require quite a few steps to set up push notifications. Below are some best practices on testing and troubleshooting Iterable push notifications.
In this article
- Testing iOS push notifications
-
Troubleshooting
- Test push on Iterable is not working on iOS
- Invalid Token
- Invalid Sandbox .p12
- Invalid Production .p12
- Invalid bundle identifier
- Iterable sends the push notification, but the iOS device doesn't receive it
- Rich push is not working
- HTTP links do not work
- Push sent from a template is failing
- iOS 10 push notifications not registering
- Testing Android push notifications
- Android Troubleshooting
Testing iOS push notifications
Here are some things to try if push notifications don't show up on device as expected.
Sending a test iOS push notification
After you've configured your push notification credentials in Iterable, send a test push. To do this:
In Iterable, navigate to Settings > Apps and websites.
Click an iOS app to view its configuration.
In the Push Credentials section, find the table row for the environment to which you'd like to send a test push notification (Sandbox or Production).
-
Click Test Push, which opens the Send test push window.
-
Enter a device token and message.
To get the push notification token directly from Xcode, run the code below and copy the printed
deviceTokenString
.NOTES
It may take some time for the certificate to propogate through the system, so your first push may take a few minutes.
Swift
import Foundation //put outside class extension Data { var hexString: String { let hexString = map { String(format: "%02.2hhx", $0) }.joined() return hexString } } //usage func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let deviceTokenString = deviceToken.hexString print(deviceTokenString) }
Troubleshooting
Test push on Iterable is not working on iOS
If Iterable is not propertly configured to send push notifications, you may see one of the following errors after sending a test push from Settings > Apps and websites.
Invalid Token
Make sure the token you are using to test push set up belongs to correct bundle id configured for the setting. For APNS_SANDBOX testing, please use a token generated by sandbox app. Similarly, for production use the token generated with production push certificate.
NOTE
If you deploy your sandbox app to TestFlight, it uses production certificate and hence it should be tested using production set up instead on sandbox/dev set up.
Invalid Sandbox .p12
This error means you are uploading production .p12 file into a sandbox congifuration. Verify the .p12 file. If it is still failing, regerate the certificate and upload a newely exported dev .p12
Invalid Production .p12
This error means you are uploading sandbox .p12 file into a production configuration. Verify the .p12 file. If it is still failing, regerate the certificate and upload a newely exported production .p12
Apple now has an option of creating one certificate with production and sandbox extension. In your Apple Developer Account, while creating certificates, look for the Apple Push Notification service SSL (Sandbox & Production) option. This will make token management easier.
Invalid bundle identifier
While uploading .p12 into Iterable platform, make sure you are uploading a relevant file for the bundle id specified. You may recieve an error shown above if the bundle identifier on .p12 doesn't match the bundle identifier mentioned in the set up.
Iterable sends the push notification, but the iOS device doesn't receive it
Make sure your app has the user's permission to send a push notification.
If you do not receive a test push, then our certificates may need to be re-exported Please follow the steps from the beginning.
NOTE
To test iOS push notifications, you must use a real device. You cannot use the iOS simulator.
Before sending a test push notification, verify that a device is registered on the recipient's user profile in Iterable. When you send a test push notification to a user profile, Iterable fetches the device token from their user profile.
To send a test message to a particular user, open up a push notification template in Iterable, click Send test message, and then specify a user profile using one of the options.
If the device receives your message, you are ready to send campaigns.
If you do not receive the message but do receive the test push in step 2, check that the code in your app is identifying the email address to which you send the proof.
Swift
IterableAPI.email = "user@example.com"
Rich push is not working
Make sure your system notifications are working. If not, follow the troubleshooting steps above.
For rich push notifications to work, you must add
IterableAppExtensions
to your Xcode project. For more information, read Advanced iOS Push Notifications.
HTTP links do not work
iOS apps, by default, do not load links in http
form for better security. To
learn how to bypass this restriction, see Apple's article,
Preventing Insecure Network Connections.
Push sent from a template is failing
There are multiple reasons why your push template proof may fail even when a test push works.
Make sure email address you are testing with has a devices array on their user's profile. If you are having trouble registering device on user's profile, please refer to user registration troubleshooting guide.
Check if notificationsEnabled is set to true. notificationsEnabled is set to false when user disables permission to receive push notification.
Check if endpointEnabled is set to true. endpointEnabled is set to false, if user uninstalls the app, making device token no longer valid for push.
iOS 10 push notifications not registering
With the introduction of iOS 10 and Xcode 8, and there are a number of changes made to push notifications.
In particular, note the following change to the aps-environment
entitlement:
Scenario: If you upgrade to iOS 10 and Xcode 8, and push notifications don't
work, check to see if there are errors from didFailToRegisterForRemoteNotificationsWithError
.
If you get the following error on iOS 10 but not iOS 9, you will need to
enable push entitlements locally.
fail to register with error Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo={NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
With Xcode 8, the entitlements are set from your local entitlements file, rather than from the provisioning profile you created on the Apple Developer Portal. The entitlements will now need to be added to your Xcode build under Capabilities, in addition to in your provisioning profile.
Testing Android push notifications
To verify Android set up, go to Firebase Console. Send a test message from Cloud Messaging in Firebase to test your set up.
Sending a test Android push notification
After you have verified the Firebase setup:
- Sign in to Iterable.
- Open up your your project.
- Click on Settings and open Mobile Apps.
- Click on the Android App and make sure the Firebase API key has been configured.
- Click on Test Push and enter the device token for your test device.
- Add a test payload and send the test.
Fetch Push Payload
To see what data is being sent in the push payload, call this method:
IterableApi.getInstance().getPayload();
This will also contain the custom metadata you added to your template in Iterable.
Android Troubleshooting
Unable to create mobile push integration
Make sure you have a correct API Key from Firebase. You can locate this key by opening your Firebase project and navigating to Settings > Project Settings > Cloud Messaging and looking in the Project Credentials section.
Test notification is not working on Android
Make sure you have followed Firebase Set up and test from Firebase works. Check Firebase Setup for details.
Verify the device token you are entering is correct
Iterable sends the push notification, but the Android device doesn't receive it
All push from Iterable platform are received as data messages in the app. Iterable SDK renders the notification. Thus, make sure you do NOT have 'OS Notifications' enabled when using Iterable SDK integration. Also make sure your app has user's permission to send push.