#import <Purchasely/Purchasely-Swift.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Purchasely startWithAPIKey:@"API_KEY"
appUserId:@"USER_ID"
observerMode:true
eventDelegate:nil
uiDelegate:nil
confirmPurchaseHandler:nil
logLevel: LogLevelInfo];
return YES;
}
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) .observerMode(true) .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()
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).observerMode(true).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();
If your user change within your app life cycle, please update Purchasely like that:
Purchasely.userLogin(with:"123456789")
[Purchasely userLoginWith:@"123456789"];
Purchasely.userLogin("123456789") { refresh ->if (refresh) {//you can call your backend to refresh user information }}
Purchasely.userLogin("123456789", refresh -> {if(refresh) {//you can call your backend to refresh user information }returnnull;});
Purchasely.userLogin('123456789').then((refresh) => {if (refresh) {//call your backend to refresh user information }});
Purchasely.userLogin("123456789");
When a user logs out perform a:
Purchasely.userLogout()
[Purchasely userLogout];
Purchasely.userLogout()
Purchasely.userLogout();
Purchasely.userLogout();
Purchasely.userLogout();
Purchasely won't consume your purchases or acknowledge purchases made.
On iOS we won't finish the transaction of your consumables that will remain in the queue if you don't do that in your code.
On Android the transactions will be cancelled and refunded after 3 days.
Sync your purchases (Android only)
When a purchase or a restoration is made with your current flow, call the synchronize() method of our SDK to send the receipt to our backend. This allow us to save the receipts on our server to prepare for your migration.