การซื้อจากข้อความในแอป iOS
เพื่อให้ผู้ใช้ของคุณสามารถทำการซื้อได้โดยตรงจากข้อความในแอปที่แสดงในแอป iOS ของคุณ คุณสามารถใช้งานโซลูชันสำเร็จรูปสำหรับ Rich Media ของคุณและเพิ่ม callbacks เพื่อรับข้อมูลเพิ่มเติมเกี่ยวกับการซื้อในแอป
การใช้งาน JavaScript ของ Rich Media
Anchor link toในการใช้งานการซื้อในแอปใน Rich Media ของคุณ ให้ใช้ การเรียกฟังก์ชัน JavaScript แบบง่าย:
pushwooshImpl.makePurchaseWithIdentifier("Premium"); // product identifier specified in your App Store product informationเมธอด AppDelegate สำหรับ callbacks
Anchor link toหากคุณต้องการให้ callbacks ทำงานเมื่อมีการซื้อ ให้ใช้งาน โปรโตคอล PWPurchaseDelegate ดังนี้:
- ทำให้ AppDelegate ของโปรเจกต์ของคุณเป็นไปตามโปรโตคอล PWPurchaseDelegate:
@interface AppDelegate : PWAppDelegate <PushNotificationDelegate, PWPurchaseDelegate>- ใช้งานเมธอดของ PWPurchaseDelegate ใน AppDelegate ของคุณ:
#pragma mark - Purchase delegate methods- (void) onPWInAppPurchaseHelperPaymentComplete:(NSString*) identifier { NSLog(@“Custom purchase delegate -- payment complete for identifier: %@“, identifier);}-(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products { NSLog(@“Custom purchase delegate -- retrieved list of products”);}-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error { NSLog(@“Custom purchase delegate -- payment failed with identifier %@ and error %@“, identifier, error.description);}รายการเมธอด PWPurchaseDelegate ที่มีให้ใช้งาน
Anchor link toรายการผลิตภัณฑ์
Anchor link to@protocol PWPurchaseDelegate <NSObject>// ข้อมูลโดยละเอียดเกี่ยวกับรายการผลิตภัณฑ์ในแอปของคุณ-(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products;@endการทำธุรกรรมสำเร็จ
Anchor link to@protocol PWPurchaseDelegate <NSObject>// การทำธุรกรรมที่ประมวลผลสำเร็จ<strong>-(void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;</strong>@endการทำธุรกรรมล้มเหลว
Anchor link to@protocol PWPurchaseDelegate <NSObject><strong>// การทำธุรกรรมที่ล้มเหลว</strong>-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;@endโปรโมทจาก App Store
Anchor link to@protocol PWPurchaseDelegate <NSObject>// การซื้อในแอปเริ่มต้นจาก App Store และการทำธุรกรรมจะดำเนินต่อไปในแอปของคุณ-(void)onPWInAppPurchaseHelperCallPromotedPurchase:(NSString* _Nullable)identifier;@endการกู้คืนธุรกรรมที่เสร็จสมบูรณ์ล้มเหลว
Anchor link to@protocol PWPurchaseDelegate <NSObject>// เกิดข้อผิดพลาดขณะกู้คืนธุรกรรม-(void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;@end