import io.purchasely.ext.PurchaselyPurchasely.Builder(applicationContext) .apiKey("API_KEY") .logLevel(LogLevel.DEBUG) // set to warning or error for release .userId("USER_ID") .eventListener(eventListener) .runningMode(PLYRunningMode.Full) .stores(listOf(GoogleStore(), HuaweiStore())) .build()// When you are ready for Purchasely to initialize,// you must call start() method that will grab configuration and products// from the selected stores.Purchasely.start { isConfigured ->}
List<Store> stores =newArrayList();stores.add(newGoogleStore(),newHuaweiStore());new Purchasely.Builder(getApplicationContext()).apiKey("API_KEY").logLevel(LogLevel.DEBUG) // set to warning or error for release.userId("USER_ID").eventListener(this).runningMode(PLYRunningMode.Full.INSTANCE).stores(stores).build();// When you are ready for Purchasely to initialize,// you must call start() method that will grab configuration and products// from the selected stores.Purchasely.start(isConfigured -> {null;});
import Purchasely from'react-native-purchasely';/*** @params String apiKey* @params StringArray stores : may be Google, Amazon and Huawei* @params String userId* @params Purchasley.LogLevel logLevel* @params RunningMode runningMode**/Purchasely.startWithAPIKey('API_KEY', ['Google'],'USER_ID',Purchasely.logLevelDebug,RunningMode.FULL);
/*** @params String apiKey* @params StringArray stores : may be Google, Amazon and Huawei* @params String userId* @params Purchasley.LogLevel logLevel* @params Purchasely.RunningMode runningMode**/Purchasely.startWithAPIKey('API_KEY', ['Google'],null,Purchasely.LogLevel.DEBUG,Purchasely.RunningMode.full);
/*** @params String apiKey* @params StringArray stores : may be Google, Amazon and Huawei* @params String userId* @params PLYLogLevel logLevel* @params PLYRunningMode runningMode**/bool configured =awaitPurchasely.startWithApiKey('API_KEY', ['Google'],null,PLYLogLevel.debug,PLYRunningMode.full );if (!configured) {print('Purchasely SDK not configured');return;}
The userID parameter is optional and allows you to associate the purchase to a user instead of a device.
Display a placement
Paywalls are displayed by calling a Placement.
A Placement represents a specific location in your user journey inside your app (e.g. Onboarding, Settings, Home page, Article). A placement is linked to a paywall and a single paywall can be used for different Placements. You can create as many Placements as you want, and this is the only thing that ties the app developer to the marketer.
Once the placements are defined and called from the app, you can change the displayed paywall remotely without any developer action.
You can also preload paywalls asynchronously using fetchPresentation method
val placementId ="onboarding"val contentId ="my_content_id"//or nullPurchasely.presentationFragmentForPlacement(placementId, contentId) { result, plan -> Log.d("Purchasely", "Result is $result with plan $plan")}