Logout Device

Prev Next

Overview

Use the logout API to disassociate the current device from the active user session in Mapp Engage. The SDK clears the user-specific state on the device so that subsequent push notifications and inbox content are no longer tied to the previous user.

Use Case

  1. Purpose:

    • End the user-to-device association after the user signs out of the host app.

    • Optionally control whether the device remains addressable for push after the user is removed.

  2. Benefits:

    • Prevent user-targeted notifications from reaching a device after sign-out.

    • Keep the device addressable for anonymous campaigns when desired.

Implementation Details

  1. Logout API: Call logoutWithOptin: on the shared Appoxee instance. The method takes a BOOL flag (optin) that controls whether the device remains subscribed to push after the user is removed from the device.

    Appoxee.shared()?.logout(withOptin: true)   // device stays opted in
    Appoxee.shared()?.logout(withOptin: false)  // device is opted out
    // Logout the user from the device
    [[Appoxee shared] logoutWithOptin:YES];   // device stays opted in
    [[Appoxee shared] logoutWithOptin:NO];    // device is opted out

    Warning:

    Confirm the exact tenant-side semantics of the optin flag with your Mapp Cloud account manager before relying on a specific value. The flag controls the device's subscription status after the user is removed; the precise effect on anonymous push, inbox visibility, and tag retention can depend on tenant configuration.

  2. Re-enable push for the device: If push has been disabled, re-enable it using disablePushNotifications: with NO:

    Appoxee.shared()?.disablePushNotifications(false) { error, data in
        if error == nil {
            print("Push re-enabled.")
        }
    }
  3. Clear additional app data on logout: Optionally clear cached data and user-specific preferences in the host app:

    UserDefaults.standard.removeObject(forKey: "user_data")

Keep in mind:

  • logoutWithOptin: returns void — there is no completion handler for the logout call itself.

  • Test both YES and NO end-to-end against your Mapp Engage tenant to verify the post-logout push and inbox behaviour you expect.

  • Inform users when sign-out also affects push subscription on the device.