Promo campaigns
Learn how to display personalized promo offers to your customers using Adapty SDK
Promo Campaigns help you to increase revenue with targeted offers for your customers. You can use them to upsell, convert freemium users to paid ones, and win back churned subscribers.
Important
Make sure to upload the push certificate for iOS and Firebase Cloud Messaging (FCM) server key for Android in an Adapty Dashboard, without them, we can't send push notifications
Getting an available promo offer
To get an available promo offer for the user, call .getPromo()
method
Adapty.getPromo { (promo, error) in
if (error == nil && promo != nil) {
// handle available promo
}
}
Adapty.getPromo { promo, error ->
if (error == null && promo != null) {
// handle available promo
}
}
try {
final AdaptyPromo? promo = await Adapty.getPromo();
} on AdaptyError catch (adaptyError) {}
catch (e) {}
try {
const promo = await adapty.promo.getPromo();
} catch (error: AdaptyError) {}
Response parameteres:
- Promo: a
PromoModel
(iOS | Android | Flutter | Rn object). This model contains info about the available promo offer. It can be null when there's no offer available (which is fine).
Listening for promo updates
Whenever the user's promo offer changes, Adapty will fire an event. To receive promo offers updates, follow below:
// Extend AdaptyDelegate using didReceivePromo method:
extension AppDelegate: AdaptyDelegate {
func didReceivePromo(_ promo: PromoModel) {
// handle available promo
}
}
// You can respond to any changes in the user's promo by setting an optional OnPromoReceivedListener
Adapty.setOnPromoReceivedListener(object : OnPromoReceivedListener {
override fun onPromoReceived(promo: Promo) {
// handle available promo
}
})
Adapty.promosReceiveStream.listen((AdaptyPromo promo) {
});
adapty.addEventListener('onPromoReceived', (data) => {
// do something
});
Handling push notifications
You have to pass push notifications to Adapty SDK, so it can handle promo notifications and respond accordingly. Here's an example of doing this
Android SDK
Check the Push Notifications section to get instructions on configuring push notifications.
React Native
You have to pass push notifications to Adapty SDK to check, whether notifications are promo-based. To do this you have to tweak
AppDelegate.m
for iOS notificationsMake sure, that you have Swift Bridging Header in your project set up
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Adapty.handlePushNotification(userInfo) { (_) in
completionHandler(UIBackgroundFetchResult.newData)
}
}
// imports ...
@import Adapty;
#import <Adapty/Adapty-umbrella.h>
// and then inside AppDelegate:
// @implementation AppDelegate
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[Adapty handlePushNotification:userInfo completion:^(AdaptyError *_) {
completionHandler(UIBackgroundFetchResultNewData);
}];
}
Updated 10 months ago