When integrating Pushwoosh into an Android application that already uses Firebase Cloud Messaging (FCM), it's important to understand how Pushwoosh works with your existing setup. Pushwoosh acts as an advanced layer on top of FCM, using it as the underlying delivery service.
Here’s how to handle migration, user subscriptions, and device registration:
1. Migrating from FCM Topics to Pushwoosh Tags
There is no feature to automatically import FCM topic subscriptions into Pushwoosh. The recommended approach is to map your topics to Pushwoosh Tags within your application logic.
- In your app's code, retrieve the list of FCM topics a user is currently subscribed to.
- Use the Pushwoosh SDK's
setTagsmethod to assign corresponding Custom Tags to the user's device. This ensures that your existing user segmentation is replicated in Pushwoosh.
2. Managing User Subscriptions and Unsubscribing
It's crucial to distinguish between removing a Tag and completely unsubscribing a device.
- Removing a Tag: When you remove a Tag from a device, it is only excluded from Segments that use that specific Tag as a filter. The device can still receive notifications sent to other Segments it qualifies for or messages sent to all users.
- Fully Unsubscribing: To completely stop a device from receiving all push notifications, you must call the
unregisterDeviceAPI method. This removes the device's push token from our system.
Important: After unregisterDevice is called, the Pushwoosh SDK might automatically re-register the device the next time the user opens the app. To prevent this, you must implement logic in your app to check a user's opt-out preference before initializing the push registration process on app launch.
3. Device Registration and Permissions
Pushwoosh respects existing user permissions.
- Permission Prompts: If a user has already granted notification permissions to your app at the operating system level, the Pushwoosh SDK will not show another permission prompt.
- Device Registration: When you initialize the Pushwoosh SDK (e.g., by calling
Pushwoosh.getInstance().registerForPushNotifications()), it automatically obtains the existing FCM push token and registers the device with Pushwoosh servers. This creates a unique Pushwoosh Hardware ID (HWID) for the device. - Handling Token Refreshes: FCM tokens can change. To ensure Pushwoosh always has the current token, you should handle token refreshes within your
FirebaseMessagingServiceimplementation.@Override public void onNewToken(String s) { super.onNewToken(s); PushwooshFcmHelper.onTokenRefresh(s); }
Comments
0 comments
Please sign in to leave a comment.