Purchasely
Rechercher…
Deeplinks automations
Purchasely supports the use of Deeplinks to trigger different actions to improve conversion, retention and upsell. You can send a Push or an email with that deeplink and Purchasely will open the requested presentation or page for you.
Here are the actions Purchasely supports:
  • Display a product page (paywall)
  • Display the user subscriptions
  • Display the cancellation survey
  • Update credit card (Deeplink to App Store)

Integration

To integrate these automations you need 2 things:
  • Pass the deeplink to Purchasley when it is received by the application
  • Allow Purchasely to display content over your interface
The first thing you need to do is to pass the deeplink URL to Purchasely when your app receives it:
Swift
Objective-C
Kotlin
Java
React Native
Cordova
Flutter
1
// ---------------------------------------------------
2
// If you are **NOT** using SceneDelegate
3
// ---------------------------------------------------
4
5
// AppDelegate.swift
6
7
import Purchasely
8
9
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
10
// You can chain calls to multiple handler using a OR
11
return Purchasely.handle(deeplink: url)
12
}
13
14
// ---------------------------------------------------
15
// If you are using SceneDelegate
16
// ---------------------------------------------------
17
18
// SceneDelegate.swift
19
20
import Purchasely
21
22
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
23
24
// …
25
26
if let url = connectionOptions.urlContexts.first?.url {
27
_ = Purchasely.handle(deeplink: url)
28
}
29
}
30
31
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
32
if let url = URLContexts.first?.url {
33
_ = Purchasely.handle(deeplink: url)
34
}
35
}
36
Copied!
1
// ---------------------------------------------------
2
// If you are **NOT** using SceneDelegate
3
// ---------------------------------------------------
4
5
// AppDelegate.m
6
7
#import <Purchasely/Purchasely-Swift.h>
8
9
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
10
// You can chain calls to multiple handler using a OR
11
return [Purchasely handleWithDeeplink:url];
12
}
13
14
// ---------------------------------------------------
15
// If you are using SceneDelegate
16
// ---------------------------------------------------
17
18
// SceneDelegate.m
19
20
#import <Purchasely/Purchasely-Swift.h>
21
22
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
23
24
// …
25
26
NSURL *url = connectionOptions.URLContexts.allObjects.firstObject.URL;
27
if (url != nil) {
28
[Purchasely handleWithDeeplink:url];
29
}
30
}
31
32
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
33
NSURL *url = URLContexts.allObjects.firstObject.URL;
34
if (url != nil) {
35
[Purchasely handleWithDeeplink:url];
36
}
37
}
Copied!
1
class MyActivity : FragmentActivity() {
2
3
override fun onCreate(savedInstanceState: Bundle?) {
4
super.onCreate(savedInstanceState)
5
6
//retrieve intent data to get deeplink that opened your activity
7
val data = intent.data
8
if(data != null) {
9
//Purchasely sdk will return true if it handles the deeplink
10
val isHandledByPurchasely = Purchasely.handle(data)
11
}
12
}
13
14
}
Copied!
1
public class MyActivity extends FragmentActivity {
2
3
@Override
4
protected void onCreate(@Nullable Bundle savedInstanceState) {
5
super.onCreate(savedInstanceState);
6
7
//retrieve intent data to get deeplink that opened your activity
8
Uri data = getIntent().getData();
9
if(data != null) {
10
//Purchasely sdk will return true if it handles the deeplink
11
boolean isHandledByPurchasely = Purchasely.handle(data);
12
}
13
}
14
}
Copied!
1
Purchasely.handle('app://ply/presentations/')
2
.then((value) => console.log('Deeplink handled by Purchasely ? ' + value));
Copied!
1
// If you grab the deeplink inside your Cordova code you can call
2
Purchasely.handle("app://ply/presentations/", (handled) => {
3
console.log("Was deeplink handled by Purchasely? " + handled);
4
});
Copied!
1
Purchasely.handle('app://ply/presentations/')
2
.then((value) => print('Deeplink handled by Purchasely ? $value'));
Copied!

Allow display

Your app might have a launch routine that requires to be fulfilled before another screen can be displayed. It can be splash screen, on boarding, login …
The display of Purchasely deeplinks is deferred until you authorize it. Once your app is ready, notify Purchasely.
Swift
Objective-C
Kotlin
Java
React Native
Cordova
Flutter
1
Purchasely.isReadyToPurchase(true)
Copied!
1
[Purchasely isReadyToPurchase: YES];
Copied!
1
Purchasely.isReadyToPurchase = true
Copied!
1
Purchasely.setReadyToPurchase(true);
Copied!
1
Purchasely.isReadyToPurchase(true);
Copied!
1
Purchasely.isReadyToPurchase(true);
Copied!
1
Purchasely.isReadyToPurchase(true);
Copied!

Get presentation result

When a deeplink is called, as you don't instanciate the paywall yourself, no closure will be called to tell you what happened. You can retrieve the result of the user action in a paywall opened with a deeplink by setting a DefaultPresentationResultHandler.
Swift
Objective-C
Kotlin
Java
React Native
Cordova
Flutter
1
Purchasely.setDefaultPresentationResultHandler { [weak self](result, plan) in
2
switch result {
3
case .purchased:
4
break
5
case .restored:
6
break
7
case .cancelled:
8
break
9
@unknown default:
10
break
11
}
12
}
Copied!
1
[Purchasely setDefaultPresentationResultHandler:^(enum PLYProductViewControllerResult result, PLYPlan * _Nullable plan) {
2
switch (result) {
3
case PLYProductViewControllerResultPurchased:
4
break;
5
case PLYProductViewControllerResultRestored:
6
break;
7
case PLYProductViewControllerResultCancelled:
8
break;
9
default:
10
break;
11
}
12
}];
Copied!
1
Purchasely.setDefaultPresentationResultHandler { result, plan ->
2
/* You can set a callback to know when your user purchased a product */
3
when(result) {
4
PLYProductViewResult.PURCHASED -> Log.d("Purchasely", "Purchased $plan")
5
PLYProductViewResult.CANCELLED -> Log.d("Purchasely", "Cancelled purchase of $plan")
6
PLYProductViewResult.RESTORED -> Log.d("Purchasely", "Restored $plan")
7
}
8
}
Copied!
1
Purchasely.setDefaultPresentationResultHandler(new ProductViewResultListener() {
2
@Override
3
public void onResult(@NotNull PLYProductViewResult result, @org.jetbrains.annotations.Nullable PLYPlan plan) {
4
/* You can set a callback to know when your user purchased a product */
5
switch (result) {
6
case PURCHASED:
7
break;
8
case CANCELLED:
9
break;
10
case RESTORED:
11
break;
12
}
13
}
14
});
Copied!
1
Purchasely.setDefaultPresentationResultCallback((result) => {
2
console.log('Presentation View Result : ' + result.result);
3
4
if (result.plan != null) {
5
console.log('Plan Vendor ID : ' + result.plan.vendorId);
6
console.log('Plan Name : ' + result.plan.name);
7
}
8
});
Copied!
1
Purchasely.setDefaultPresentationResultHandler((result) => {
2
console.log("Presentation View Result: " + result.result);
3
4
if (result.plan != null) {
5
console.log("Plan Vendor ID: " + result.plan.vendorId);
6
console.log("Plan Name: " + result.plan.name);
7
}
8
});
Copied!
1
Purchasely.setDefaultPresentationResultCallback(
2
(PresentPresentationResult value) {
3
print('Presentation Result : ' + value.result.toString());
4
5
if (value.plan != null) {
6
//User bought a plan
7
}
8
});
Copied!
The callback PLYProductViewControllerResult(iOS) / ProductViewResultListener (Android) is optional, you can set to null if you do not need it. You can override it when you display a presentation directly.
Product
You can open a product presentation directly to the user with the default presentation or a specific one used for a specific purpose / promotion.
⚠️ This kind of push requires users opt-in (see App Store Review Guidelines - 4.5.4).
app_scheme://ply/presentations/PRESENTATION_VENDOR_ID
app_scheme://ply/presentations app_scheme://ply/placements/PLACEMENT_ID app_scheme://ply/placements
Cancellation survey
Cancellation survey can be triggered to get some feedback by the user after a subscription cancellation.
app_scheme://ply/cancellation_survey
app_scheme://ply/cancellation_survey/PRODUCT_VENDOR_ID
Subscriptions
This deeplink will open the subscriptions view inside the app.
app_scheme://ply/subscriptions
Update billing
This deeplink will open the App Store / Play Store setttings for the user to updates its credit card after a payment error.
app_scheme://ply/update_billing
Copier le lien
Éditer sur GitHub