Self-promotion
Purchasely.plan(with: "PLAN_ID",
success: { (plan) in
// Get the regular price like "$1.99 / month"
guard let price = plan.localizedFullPrice else { return }
// In case there is an active promotion we display it followed by the regular price
// for example: "$0.99 / week during 2 weeks then $1.99 / month"
if plan.hasIntroductoryPrice,
let introPrice = plan.localizedFullIntroductoryPrice,
let introDuration = plan.localizedIntroductoryDuration {
self.priceLabel.text = "\(introPrice) during \(introDuration) then \(price)"
} else {
self.priceLabel.text = price
}
},
failure: { (error) in
// Hide advertising
})[Purchasely planWith:@"PLAN_ID"
success:^(PLYPlan * _Nonnull plan) {
// Get the regular price like "$1.99 / month"
NSString *price = [plan localizedFullPriceWithLanguage:nil];
// In case there is an active promotion we display it followed by the regular price
// for example: "$0.99 / week during 2 weeks then $1.99 / month"
if ([plan hasIntroductoryPrice]) {
NSString *introPrice = [plan localizedIntroductoryPriceWithLanguage:nil];
NSString *introDuration = [plan localizedIntroductoryDurationWithLanguage:nil];
NSString *introText = [NSString stringWithFormat:@"%@ during %@ then %@", introPrice, introDuration, price];
[priceLabel setText:introText];
} else {
[priceLabel setText:price];
}
} failure:^(NSError * _Nullable error) {
// Hide advertising
}];Last updated