iOS Troubleshooting
Problems specific to the iOS SDK. Start with the platform independent checks in Troubleshooting, especially when events are missing in the panel.
Diagnostic steps
- Check the SDK version in your
Package.resolvedorPodfile.lock. This page describes the current version. On an older version, see Older SDK versions and the Migration Guide. - Print
UserSDK.default?.userKeyafter the first ping. If it isnil, the SDK has no contact yet and does not send events. - Read the completion handlers of
ping,sendEventandtrackScreen, or setUserSDK.errorHandler, and log the errors. See Errors. - Find the contact with this key in the panel and compare it with the contact you were looking at.
- For push notifications and in-app messages, test on a physical device and check that
UIBackgroundModeswithremote-notificationis in the built app'sInfo.plist.
Setup and build
Contacts
After switching baseURL, events go to an unknown contact or are rejected
For example after switching from staging to production.
Cause: the contact key is stored in the Keychain and kept when baseURL changes. The SDK resets it only after the app is deleted and installed again.
Fix: delete the app from the device before testing with another workspace, or call logout(fcmToken:_:) once after switching.
Events
Events fail with notIdentified ("No user exists yet")
The completion of sendEvent, trackScreen or sendProductEvent reports false at once, with UserSDKError.notIdentified. The SDK sends no request, so a network proxy shows no event traffic at all.
Causes:
- the event was sent before the first successful
ping()of this installation, ping()is never called, or it fails (wrong key, wrong domain, no network on first launch),- the event was sent while
logoutwas in progress, before its completion handler ran. There is no contact key at that moment.
Fix:
- Call
ping()after initialization on every launch. - Check its completion. A 401 means the Mobile SDK key is wrong, regenerated, or is the REST API key. See Nothing reaches the panel.
- Send events after the ping succeeds, for example from its completion on the first launch.
- After
logout, send events from its completion handler.
Push notifications
The contact cannot be selected in a push or in-app campaign
Cause: the panel offers only contacts with a device that has a push token. Common reasons:
- no FCM token passed to the SDK,
- the token moved to another contact on the same device: a push token belongs to the device, and a ping with it moves the device to the contact that sent the ping, for example after another user logged in on that device or after
logout.
Fix:
- Check that
setFcmToken(_:)(or another method withfcmToken) runs with a non empty token. See Push Token. - Open the app, so the next ping registers the current token on the current contact.
On iOS SDK older than 1.3.0, also see Push notifications and in-app messages go to an anonymous contact.
The campaign is sent, but the push notification never appears
Causes:
- no APNs key in the Firebase project, or the Push Notifications capability is missing,
- the panel uses a service account key from a different Firebase project,
- notifications are turned off for the app in the iOS Settings app.
Fix:
- Check the APNs key in Firebase Console → Project settings → Cloud Messaging.
- Compare the Firebase project in
GoogleService-Info.plistwith the one in the panel. - Check the permission in the iOS Settings app.
The push notification arrives without its image
Causes:
- no Notification Service Extension, or it does not call
NotificationExtensionHelper, - the image URL is not HTTPS, is not public, or the file is larger than iOS accepts,
- the image server answers too slowly.
Fix:
- Add the extension as described in Show images.
- Use a public HTTPS URL to a small image file.
Users tap push notifications, but the panel shows no clicks
Causes:
- your
UNUserNotificationCenterDelegatedoes not forward taps to the SDK, - another library replaced your notification center delegate,
- your app passes taps to
handleNotification(_:), which never counts a click.
Fix:
- Call
handleNotificationClick(_:)inuserNotificationCenter(_:didReceive:withCompletionHandler:). - Check which object is
UNUserNotificationCenter.current().delegateafter launch.
The panel shows clicks for push notifications nobody tapped
The number of clicks is often close to the number of deliveries. It also happens for users who did not grant notification permission.
Cause: your app calls the deprecated handleNotification(userInfo:) from userNotificationCenter(_:willPresent:withCompletionHandler:) or from application(_:didReceiveRemoteNotification:fetchCompletionHandler:). iOS calls these methods for notifications that were only received, willPresent even without notification permission, and the deprecated method counts every call as a click.
Fix: switch to the new methods:
- Call
handleNotificationClick(_:)inuserNotificationCenter(_:didReceive:withCompletionHandler:). - Call
handleNotification(_:)inapplication(_:didReceiveRemoteNotification:fetchCompletionHandler:), and inwillPresentif you like. It never counts a click. In-app messages arrive throughdidReceiveRemoteNotification, so they keep working.
In-app messages
Push notifications work, but in-app messages never show up
Causes:
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)is missing, does not callhandleNotification(_:), or is in a class iOS does not use as the app delegate,- the Remote notifications background mode is missing from the built
Info.plist, - the message was sent while the app was closed (swiped away), or more than 6 hours before the app was opened,
- your app calls
registerForRemoteNotifications()only after the user allows notifications, so users who decline get no in-app messages.
Fix:
- Add the method to the real app delegate. In SwiftUI, to the class attached with
UIApplicationDelegateAdaptor. - Enable Background Modes → Remote notifications.
- With Firebase method swizzling turned off, also call
Messaging.messaging().appDidReceiveMessage(_:)there, as Firebase requires. See Firebase method swizzling. - Register with APNs and pass the FCM token whether or not the user allows notifications. In-app messages do not need notification permission.
- Test with the app open first, then in the background.
See In-App Messages.
Older SDK versions
Before 1.3.0: push notifications and in-app messages go to an anonymous contact
A logged in user stops getting push notifications or in-app messages. The panel shows anonymous contacts with the same device model, created around the time a campaign was sent.
Cause: a silent push woke the app in the background on a locked phone, and the SDK could not read the contact key. The ping sent then created a new anonymous contact and moved the push token to it.
Fix: update to 1.3.0. See Duplicate anonymous contacts from one iOS device.
On 1.2.x: the panel shows clicks for push notifications nobody tapped
Cause: the same as in The panel shows clicks for push notifications nobody tapped.
Fix: update to 1.3.0 and switch to the new methods. On 1.2.x, remove the handleNotification(userInfo:) call from willPresent.
Before 1.2.0: in-app messages do not appear when notifications are forwarded from a background queue
Cause: the app forwards notifications to the SDK from a background queue or a Task.
Fix: update to 1.2.0.
Before 1.2.0: events sent after logout fail until the next ping
sendEvent and trackScreen report "No user exists yet" after logout.
Fix: update to 1.2.0. Events sent after logout completes no longer fail with "No user exists yet". While logout is in progress, until its completion handler runs, events still report this error.
Contact support
If the problem persists, contact Positive User support through the chat widget in your workspace or on user.com, or your Customer Success Manager. Include the SDK version, iOS version and device model, the contact key from UserSDK.default?.userKey, the time of the test, the completion errors, and your notification setup (own delegate or registerForRemoteNotifications, Firebase swizzling on or off).