Troubleshooting iOS

Common setup issues with iOS

πŸ“˜

You're Viewing User Model Documentation πŸŽ‰

OneSignal is in the process of migrating from a device-centric model (player ID) to a new user-centric data model (OneSignal ID). To learn more, check out the User Model Migration Guide.

Please refer to Version 9 of our documentation for device-centric information.

Troubleshooting iOS Steps

πŸ“˜

Troubleshooting Steps

Check this page first for common issues based on iOS Setup.

Try the example project on our Github repository.

If stuck, contact support directly or email [email protected] for help.

For faster assistance, please provide:

  • Your OneSignal App Id
  • Details, logs, and/or screenshots of the issue.
  • Steps to reproduce

Please follow all steps below. If you are still having issues, please reach out to support with a log generated following the steps below.

1. Double Check Setup Guide

Return to the setup guide you followed in Mobile Push Quickstart to make sure you followed all steps adding the OneSignal SDK to your app.

2. Use the latest OneSignal SDK

Make sure you are running version 5.0.0 or newer of the OneSignal SDK. See details in Mobile SDKs API Migration Guides.

3. Check below for common issues and if still not sure, send us a log.

After running through the rest of this Troubleshooting guide, use the OneSignal SDK setLogLevel method to Verbose to check the full logcat from the device when reproducing the behavior.

If you need help interpreting the logs, you can share them with [email protected] as a .txt file to help our support and engineering teams assist you.


APNS Delegate Never Fired

"APNS Delegate Never Fired" is a timeout message for when iOS doesn't fire a success or failure message if a connection is not made to Apple's APNS servers. This usually occurs in Development/Ad-hoc environments and is more rare in Production.

Please check the following:

1. Toggle WiFi on iOS Device

Try toggling WiFi on/off for the device. If possible, try another device or a different network. Check your firewall settings to make sure you are not blocking your app's access to Apple:

2. Xcode Capabilities

Make sure you have the Push Notifications Capability in the Main App Target > "Signing & Capabilities" > Push Notifications. Some users reported enabling Background Fetch in Main App Target helped reduce the frequency as well. Check that this is enabled for both Debug and Release builds. You may need to check your entitlements if these are different.

3. Other Push Dependencies

Other Dependencies, especially other Push Provider SDKs, can interfere with this. It is best to remove the other Push SDK from the app. We swizzle the AppDelegate methods and other 3rd party SDKs could be impacted.

You may or may not see in the logs: WARNING: Already swizzled UIApplication.setDelegate. Make sure the OneSignal library wasn't loaded into the runtime twice!

Common Dependency Issues:

  • React Native Push Notifications appears to add methods within the native AppDelegate.m file. Search the project in Xcode for RNCPushNotificationIOS and comment out that code.

  • mParticle needs to have it to work with swizzling instead of delegate proxy.

4. Cocoapods

If using Cocoapods, run $ sudo gem install cocoapods again to get updated, then pod update to update your pods. Make sure to remove any pods that you do not use anymore (especially other push SDKs).

In your Podfile, check if you added abstract_target. This can cause issues, more detail: https://github.com/OneSignal/OneSignal-iOS-SDK/issues/180

5. Logs

After the above steps. If you are still having issues it is best to plug the device into Xcode and use our SetLogLevel method to Verbose. Then uninstall and re-build the app on the device. This will help log any errors.


No Such Module 'OneSignal'

This is likely an issue with derived data or the runpath_search_paths build setting, but to make it less flaky you can actually remove the OneSignalXCFramework from your podfile completely (it will still be included by the react native dependency in your main target). Then in Xcode navigate to the Notification Service Extension project settings and add the following XCFrameworks as dependencies:

OneSignalCore.xcframework
OneSignalOutcomes.xcframework
OneSignalExtension.xcframework

The Notification Service Extension target's Frameworks and Libraries should go from this:

To looking like this:


Clicks Not Counting

Make sure your app is initializing OneSignal from didFinishLaunchingWithOptions and from the main thread. Otherwise it can miss the click event if the app is cold started from a click.

If you have any other SDKs or libraries handing push notifications, then it is possible it is an issue with swizzling the iOS click handler and conflicting with OneSignal.

URL Not working

ERROR: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Make sure your URL is HTTPS. HTTP urls will not work unless you set NSAppTransportSecurity to NSAllowsArbitraryLoads in your Xcode .plist.

❗️

About App Transport Security

Please do not leave NSAllowsArbitraryLoads enabled when releasing your app to the App Store, as this can create a security vulnerability in your app. For more information, please read Apple's Security Overview

Notification is shown but media attachments are not displayed

  1. Open your attachment URL in a web browser. Make sure it is a direct link to the image, it can't be part of an HTML page. Also redirects are not supported.

  2. Make sure your URL is HTTPS. HTTP urls will not work unless you set NSAppTransportSecurity to NSAllowsArbitraryLoads in your Xcode .plist.

  3. Make sure your url ends with the correct file extension. If the URL doesn't contain a file extension you can add it as a parameter by adding ?filetype=file.jpg for example to the end of your URL.

  4. Please double check you have correctly added the NotificationServiceExtension noted in step 1 of the iOS Setup guide.

  5. If you correctly added the OneSignal Notification Service Extension and rich push notifications (images, buttons) still don't appear, make sure that the Deployment Target in the Extension service matches the deployment target of your application.

Notification is shown but action buttons are not displaying

Please double check you have correctly added the NotificationServiceExtension noted in step 1 of the iOS Setup guide.

Debug the Notification Service Extension

  1. Double check that you followed all setup instructions first, please see the SDK docs your are using for more on this.

  2. The 2 debugging lines in the .m source we provide are 2 ways to confirm the notification service extension is running.

self.bestAttemptContent.body = [@"[Modified] "
stringByAppendingString:self.bestAttemptContent.body];

This line will add "[Modified] " to the beginning of all your notification bodies. You should see this on all notifications on your device.

NSLog(@"Running NotificationServiceExtension");

This will add an entry to the device log when the extension is run. You can view this in Xcode under Window > "Devices and Simulators". Select your device on the left and select "View Device Logs.

We recommend clearing the log before sending a notification to test as it can grow quickly. Copy the log and search for the debug entry "Running NotificationServiceExtension".

We don't recommend trying to attach to the extension process with the debugger in Xcode through the Debug menu. Doing so can create issues with it launch so we recommend restarting your device if you have tried doing so.

Lastly the Notification Service Extension will only run if you have set our Action Buttons, a Media Attachment, or have set mutable content on the notification so make sure your test notifications have one of these set.


Embedded Binary Not Signed With Same Certificate

You will see this error when you opt out of automatic signing and your Main Target and Notification Service Extension are not signed under the same certificate.

  1. Select the target and uncheck "Automatically Manage Signing"
  2. Choose the Provisioning Profile that you'd like to use
471

Manually signing your app

  1. Go to Build Settings > Signing and ensure that the Code Signing Identity has the appropriate certificates
  2. Still under Signing settings, check that Code Signing Style is set to manual and that you choose the provisioning profile where it applies here.
  3. Make sure that the same settings are applied for your Notification Service Extension as well.

For a more detailed explanation on this, you can view this resolution on Stack Overflow.


Previous Push Notifications Disappear

The OneSignal SDK will automatically clear previously received push notifications when the app is opened under two conditions:

  • The badge number is > 0
  • The application was opened from a push notification

This behavior is caused by our system to clear the badge number. Most app developers want this behavior, however some do not. In order to prevent this from occurring, you can add OneSignal_disable_badge_clearing = true in your application's Info.plist.


App Groups Error

Couldn't read values in CFPrefsPlistSource<0x281514780> (Domain: group.com.onesignal.example.onesignal, 
User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), 
Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for
System Containers, detaching from cfprefsd

This error is normal and results from a bug in iOS. It should appear if you have App Groups added correctly. For more info, read this comment by an Apple employee.


Can we setup multiple Notification Service Extensions for Multiple Targets in single Xcode Project?

Example, we are using multiple targets within the same Xcode Project. 2 separate apps to be uploaded to app store. Getting error "Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier" and cannot enable separate app groups for separate targets.

Unfortunately you need a separate NSE for each application. There might be a workaround with writing a custom build script that dynamically sets the bundle_id of the NSE based on the containing Apps bundle Id but this is outside the scope of OneSignal.

πŸ“˜

Still having problems? We're happy to help!

We answer most support queries in under 4 hours during the week, and under 24 hours on weekends. Simply email us at [email protected]

Include as much as you can of the following to help us find your issue quicker:

  • Version of our SDK
  • Device OS version
  • Xcode crash lock or stack trace of the app starting and the problem point
  • Any other libraries or plugins in your app
  • Details on reproducing your problem.