- 1 Minute to read
- Print
- DarkLight
Logout Device
- 1 Minute to read
- Print
- DarkLight
Overview
The Logout Device feature in iOS allows developers to disassociate a user’s device from receiving notifications after they log out. This ensures secure handling of user-specific data and a tailored notification experience.
Use Case
Purpose:
Stop push notifications for a device after the user logs out.
Protect user privacy by removing the association between the user and the device.
Benefits:
Prevent notifications from being sent to devices without an active session.
Enhance app security and ensure proper user management.
Implementation Details
Logout Device API: Call the SDK method to log out the device:
For Objective-C:
[[Appoxee shared] logoutDeviceWithCompletionHandler:^(NSError * _Nullable error) { if (!error) { NSLog(@"Device successfully logged out."); } else { NSLog(@"Failed to log out device: %@", error.localizedDescription); } }];
For Swift:
Appoxee.shared()?.logoutDevice { error in if error == nil { print("Device successfully logged out.") } else { print("Failed to log out device: \(error?.localizedDescription ?? "Unknown error")") } }
Post-Logout Notification Behavior: Ensure that after logout, the device does not receive any notifications tied to the previous user session.
Re-login Handling: Re-enable notifications when a user logs back into their account:
Appoxee.shared()?.setPushEnabled(true)
Clear Additional Data on Logout: Optionally clear cached data and user-specific preferences:
UserDefaults.standard.removeObject(forKey: "user_data")
Keep in mind:
Test logout functionality to verify that no notifications are received after logout.
Inform users that logging out will disable notifications for their account on the device.
Implement proper error handling to ensure the logout operation is successful even under poor network conditions.