Below are some recommended (but optional) additions to your user update mobile code.
In this article
NOTES
Don't feel like you need to integrate this section unless these use cases are relevant to your business.
Attribution on user profile
You can attach third-party attribution data to the user profile to leverage in your own campaign. For example, if you know a user came from an advertisement campaign for benefits over your competitors, you may want to leverage those features in a push campaign.
Each mobile attribution provider has their client-side methods for returning attribution data at time of the app launch. Below are some top mobile attribution and links to their documentation for returning attribution data.
You can attach the response of these methods to the Iterable User Profile and leverage those results in your owned media.
User logout and endpointEnabled
When the user logs out of your app, you should disable the user from receiving push notifications for the previous user. If you're using one of Iterable's mobile SDKs, you can do this by calling:
Swift
disableDeviceForCurrentUser()
Java
IterableApi.getInstance().disablePush();
If you're not using one of Iterable's SDKs, you can instead make an API call to
POST /api/users/disableDevice
,
as described in this guide.
endpointEnabled
Device tokens are required to communicate with specific devices. When a
mobile platform (such as APNS or GCM) informs that token is invalid, we set
endpointEnabled
to false
.
Why will a token be set as invalid?
A token can be set invalid by any of the following:
- When
disableDeviceForCurrentUser
has been called explicitly. - While using SDK, if app doesn’t set
autoPushRegistration
tofalse
. WhenautoPushRegistration
is set totrue
SDK automatically enables and disables the token. - When app is uninstalled.
- When a
null
value is passed intosetEmail
orsetUserId
.
Session counter best practices
The best methodology for tracking sessions is to add a counter client-side and then update the user profile on each subsequent app launch.
NOTES
You will likely not want to include Sessions as an Iterable Track Call because sessions typically occur 20x-40x more than any other event! This flooding of events will create a lot of noise and make it difficult to navigate towards signaling events.
Navigate to the AppDelegate
file in your Xcode and add this code to your applicationDidBecomeActive
:
Swift
func applicationDidBecomeActive(_ application: UIApplication) { // get current number of times app has been launched let currentCount = UserDefaults.standard.integer(forKey: "launchCount") // increment received number by one UserDefaults.standard.set(currentCount+1, forKey:"launchCount") // return counter let iter_session_counter = UserDefaults.standard.integer(forKey: "launchCount") IterableAPI.updateUser(["iter_current_app_session_counter":iter_session_counter], mergeNestedObjects: false, onSuccess: myUserUpdateSuccessHandler, onFailure: myUserUpdateFailureHandler) }
Hiding user properties
Sometimes people make mistakes and you may accidentally record a user property wrong within your Iterable production instance (yikes!). There is however an easy fix to hide unnecessary data. Navigate to the Project Settings of your Iterable project and scroll down to the User Properties listings.
You can select which User Properties you'd like to view in your project, which will hopefully save your team a lot time and effort. For more information, please checkout our Project Settings documentation.