Migration to Android SDK v.5.x.x on Xamarin
How to migrate to Android SDK v.5.x.x in a few steps
PushManager
PushManager consisted of various methods for different features. These methods are now split between different classes:
PushNotificationsManager
PushwooshNotificationSettings
PushwooshInApp
PushwooshBadge
PushwooshLocation
BaseRegistrationReceiver
BaseRegistrationReceiver was used to handle push registration and unregistration events. This receiver is now replaced by a callback mechanism:
BasePushMessageReceiver
BasePushMessageReceiver was used to imitate iOS notification behavior when receiving push notification in the foreground. It was done by cancelling incoming notification and invoking OnMessageReceive callback. Such workaround required manual registration when the app became active, and unregistration when the app went into the background.
This receiver has been replaced by NotificationServiceExtension:
This extension is also used to handle notification arrival and tap events, thus replacing all clumsy code that was used in manual Activity integration.
PushFragment
PushFragment was a lightweight alternative for the complex integration involving Activity lifecycle. On the other hand, it required FragmentActivity inheritance and implicitly used more complex Fragment lifecycle.
PushFragment and PushEventListener are now replaced by Pushwoosh#registerForPushNotifications(Callback) and NotificationServiceExtension.
Custom Push Broadcast Receiver (PW_NOTIFICATION_RECEIVER)
PW_NOTIFICATION_RECEIVER was used to customize the app's behavior when user tapped the notification. This allowed to handle notifications outside of Activity context and to open different Activities depending on notification content. Such integration used internal Pushwoosh SDK API which no longer exists.
This receiver is now completely replaced by NotificationServiceExtension:
Notification Factory
There also were some breaking changes involving notification factory:
1. AbsNotificationFactory was replaced by NotificationFactory 2. AbsNotificationFactory#onPushReceived(PushData) and AbsNotificationFactory#onPushHandle(Activity) methods replaced by NotificationServiceExtension class (onMessageReceived, startActivityForPushMessage). 3. DefaultNotificationFactory was replaced by PushwooshNotificationFactory. 4. PushData was replaced by PushMessage.
In-App Messages
1. InAppFacade was replaced by PushwooshInApp.
2. pushwoosh
object was inroduced for JavaScript native interface with following API:
getHwid(): string - returns Pushwoosh HWID of the device.
getVersion(): string - returns current Pushwoosh SDK version.
postEvent(event: string, attributes?: object, successCallback?: function, errorCallback?: function) - sends postEvent request.
sendTags(tags: object) - sends tags associated with the device.
getTags(successCallback: function, errorCallback?: function) - returns tags associated with the device.
closeInApp() - closes In-App html page.
Share your feedback with us
Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.
Last updated