miduo_client/Assets/Plugins/iOS/IAPInterface.m

85 lines
2.1 KiB
Objective-C

#import "IAPInterface.h"
#import "IAPManager.h"
@implementation IAPInterface
void TestMsg(){
NSLog(@"Msg received");
}
void TestSendString(void *p){
NSString *list = [NSString stringWithUTF8String:p];
NSArray *listItems = [list componentsSeparatedByString:@"\t"];
for (int i =0; i<listItems.count; i++) {
NSLog(@"msg %d : %@",i,listItems[i]);
}
}
void TestGetString(){
NSLog(@"Msg received from unity!!!");
NSArray *test = [NSArray arrayWithObjects:@"t1",@"t2",@"t3", nil];
NSString *join = [test componentsJoinedByString:@"\n"];
UnitySendMessage("ShopPanel", "IOSToU", [join UTF8String]);
}
IAPManager *iapManager = nil;
void InitIAPManager(){
NSLog(@"unity.log----test ~~xcode~~InitIAPManager!!!");
iapManager = [[IAPManager alloc] init];
[iapManager attachObserver];
}
bool IsProductAvailable(){
NSLog(@"unity.log----test ~~xcode~~是否可以购买!!!");
return [iapManager CanMakePayment];
}
void RequstProductInfo(void *p){
NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---01---");
NSString *list = [NSString stringWithUTF8String:p];
NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---02---");
NSLog(@"unity.log----test ~~xcode~~productKey:%@",list);
// NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---03---%@",p);
NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---03---");
[iapManager requestProductData:list];
// NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---04---%@",p);
NSLog(@"unity.log----test ~~xcode~~请求商品信息!!!---04---");
}
void BuyProduct(void *p){
NSLog(@"unity.log----test ~~xcode~~XXX---01---");
NSString *list = [NSString stringWithUTF8String:p];
NSLog(@"unity.log----test ~~xcode~~productKey:%@",list);
// NSLog(@"unity.log----test ~~xcode~~ZZZ--01----%@",p);
[iapManager buyRequest:[NSString stringWithUTF8String:p]];
// NSLog(@"unity.log----test ~~xcode~~请求购买商品!!!--02----%@",p);
// NSLog(@"unity.log----test ~~xcode~~请求购买商品!!!---02---");
}
@end