iOS SDK API  2.2014464
Reference Documentation
 All Classes Functions Properties Pages
Application Setup

Add the files

TrialPay's iOS SDK is provided as a folder, containing .h and .m files. Add these files to your project. We recommend keeping them in a group so that it would be easy to upgrade the SDK in the future

Add the frameworks

In order for the SDK to work correctly, we need you to add the following frameworks to your project:

  • AdSupport
  • MediaPlayer
  • StoreKit

Note
iOS 9 prevents plain HTTP connections, you MUST override it to enable TrialPay products. Go to your Project/Target/Info and add the dictionary NSAppTransportSecurity, with a boolean NSAllowsArbitraryLoads set to YES
TransportSecurity.png

MyViewController.h

In your main view controller header

1 ...
2 
3 #import "TrialpayManager.h"
4 
5 ...
6 
7 @interface MyMainViewController : UIViewController <TrialpayManagerDelegate>
8 
9 ...
10 

MyViewControler.m

In your main view controller module

1 ...
2 
3 @implementation MyMainViewController
4 
5 ...
6 
7 - (void)viewDidLoad {
8  [super viewDidLoad];
9  // Load the TrialPay Manager object
10  TrialpayManager* trialpayManager = [TrialpayManager getInstance];
11 
12  // Set the user id. Not required if you are using Balance API
13  [trialpayManager setSid:@"<UNIQUE_USER_ID>"];
14 
15  // ******* START TOUCHPOINT REGISTRATION SECTION ************
16  // Add the [trialpayManager registerVic:withTouchpoint:] calls here
17  // There must be at least one call to register a Vic
18  // ******* END TOUCHPOINT REGISTRATION SECTION **************
19 
20  // ******* START OF BALANCE API SECTION - 1/2 ***************
21  // Add this section if you don't handle callbacks on a server
22  //
23  // Initiate Balance API checks. Not needed if you accept callbacks to your server
24  [trialpayManager initiateBalanceChecks];
25  // ******* END OF BALANCE API SECTION ***********************
26 
27  // Get responses from Trialpay
28  [trialpayManager setDelegate:self];
29 }
30 
31 // ******* START OF BALANCE API SECTION - 2/2 ****************
32 // Listen to TrialPay's balance updates if you're using the Balance API
33 - (void)trialpayManager:(TrialpayManager *)trialpayManager balanceWasUpdatedForTouchpoint:(NSString*)touchpointName {
34  int balanceToAdd = [trialpayManager withdrawBalanceForTouchpoint:touchpointName];
35  // TODO: Add the balanceToAdd amount to the user's credits
36 }
37 // ******* END OF BALANCE API SECTION ***********************
38 
39 // Optional: Listen to TrialPay's Open event
40 - (void)trialpayManager:(TrialpayManager *)trialpayManager offerwallDidOpenForTouchpoint:(NSString*)touchpointName {
41  // TODO: Stop app sounds
42 }
43 
44 // Optional: Listen to TrialPay's Close event
45 - (void)trialpayManager:(TrialpayManager *)trialpayManager offerwallDidCloseForTouchpoint:(NSString*)touchpointName {
46  // TODO: Resume app sounds
47 }
48 
49 ...
50 
51 @end
void setSid:(NSString *sid)
int withdrawBalanceForTouchpoint:(NSString *touchpointName)
void initiateBalanceChecks()
Definition: TrialpayManager.h:17
TrialpayManager * getInstance()
Note
This must be called while the app is being loaded.
Stop all sounds before opening a touchpoint, resume on trialpay:offerwallDidCloseForTouchpoint: