Xamarin Android Customization
How to customize Pushwoosh SDK for Xamarin Android project
In App Purchase Tracking
In order to track in-app purchases you should call the SendInappPurchase
method of the PushNotificationsManager
class when a user buys a product:
sku
– the ID of the purchased productprice
– the price of the productcurrency
– the currency (ex: “USD”)
Example:
Deep Linking
Add IntentFilter attribute to your activity class that will handle the deep link as follows:
Note that deep link page name (promotion in the example) goes to the host field, notpathPrefix.
In the example above the deep link opens PromoActivity. The basic implementation below displays alert with promo id value for the sake of simplicity.
Geozone Push Notifications
To implement Geozones, add Pushwoosh.Geozones.Xamarin.Droid nuget package to your project.
To start location tracking, simply call
Note that AccessFineLocation
and AccessCoarseLocation
must be enabled in the AndroidManifest.xml for Geozones to work.
Using Badges on Android
Pushwoosh supports setting badge number on the app icon shortcut for the following Android launchers: Sony, Samsung, LG, HTC, Xiaomi, ASUS, ADW, APEX, NOVA, HUAWEI, ZUK, OPPO.
Example:
Opening Custom Activity
If you want to start a particular activity in response to push notifications, add the following IntentFilter to that activity:
Controlling Log Level
In order to assist with debugging and integration, SDK prints all requests to the console by default. When you're ready for the production build, add "PW_LOG_LEVEL" meta-data with value "ERROR" to the AndroidManifest.xml. This way only information about errors will go to the console. Other option could be one of the following:
NONE - No logs from the SDK ERROR - Display only errors in the console WARN - Display warnings and errors INFO - Display informational messages DEBUG - Even debug information is displayed now NOISE - Everything SDK can print
Using ProGuard
Add the following options if you use ProGuard:
Customizing Notification Open Behavior
If you need to select which activity to display as a result of a push notification, you can create custom NotificationServiceExtension and include fully qualified class name of your NotificationServiceExtension in metadata under “com.pushwoosh.notification_service_extension” value.
Customizing Push Notifications
To customize the view of push notifications you need to create a custom Factory, you can create custom NotificationFactory and include fully qualified class name of your NotificationFactory in metadata under “com.pushwoosh.notification_factory” value.
Private Endpoint URL
For Custom Plan subscriptions only. For more details, please contact our Sales team.
Pushwoosh provides Private endpoints for customers with Custom Plan subscriptions. To set up Private endpoint for SDK you need to add the following to your AndroidManifest.xml file:
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