iOS - Implementing Device Registration
In this guide we will dive deeper into how you should handle the device registration. When you launch()
Notificare, the device will be registered as a non-push device.
When a successful device registration takes place, we will emit an event. If you have configured a custom delegate as mentioned in the Implementation page, you can receive those intents by implementing the didRegisterDevice
delegate method from NotificareDelegate
.
extension AppDelegate: NotificareDelegate {
func notificare(_ notificare: Notificare, didRegisterDevice device: NotificareDevice) {
}
}
You can also check the details of the currently registered device.
Notificare.shared.device().currentDevice
The onReady
method in NotificareDelegate
will also be called when all Notificare modules has been launched, including a successful device registration.
Additionally, you can verify whether Notificare is ready at any point by calling Notificare.shared.isReady
.
Assign a user to the device
By default, a device is registered as an anonymous user. However, to fully use push notifications in your Actito omni-channel strategy, simply registering an anonymous device is not what you want. For example, if you authenticate your users, you will want to assign user information to the registered device as shown below.
Notificare.shared.device().updateUser(userId: "7f42bedc-d74b-4c64-a5cf-76bcc5130b05", userName: "John Doe") { result in
}
After that, the device will remain registered with that userId
/ userName
until you explicitly set the user as anonymous. Depending on the way you authenticate users, you might want to check the logged-in state on launch (in the onReady) and change it if necessary. Forcing registration as anonymous can be best achieved by setting userId
and userName
to null
.
Only the userId will be used to match devices to profiles in your Actito DB.
The userName is only used to provided additional information.
Notificare.shared.device().updateUser(userId: nil, userName: nil) { result in
}
To choose the proper user ID:
- The data must be available as a key in Actito thanks to the data synchronization between your system and Actito.
- The data must be available on your website (through logging into a client space).
Please use an attribute which is already defined as unique on your Actito profile table.
If you need to add a new unique attribute, this is possible, but be careful because it could have impacts on your data synchronization process between your system and Actito. Ask your Integration Data Expert if necessary.
Override Device Language
By default, we will automatically collect the language and region of a device based on the Locale of the device. For most cases this will be enough but for those cases where you would like to override the device language and region combination to a strict selection of languages, you can do so by invoking the following method:
Notificare.shared.device().updatePreferredLanguage("en-US") { result in
}
Eventually, you can always retrieve the preferred language by calling the following method:
Notificare.shared.device().preferredLanguage