MightyIO-iOS-Pod 将提供您与 MightyIO 交云所需的方法。它包含登录、设置 Mighty 丝带、显示/隐藏丝带以及完成 Mighty 购买后解锁物品/功能的方法。
#import <MightyIO-iOS-Pod/Mighty.h>
在您的 AppDelegate 中,在 didFinishLaunchingWithOptions 方法中实例化 Mighty
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[Mighty initWithAuthToken:@"authtoken"];
// Override point for customization after application launch.
return YES;
}
[[Mighty sharedInstance] makeRibbonWithCenter:CGPointMake(260, 45) inViewController:self withIntroModalOnFirstLaunch:YES];
或 [[Mighty sharedInstance] makeRibbonWithIBOutlet:smRibbonOutlet inViewController:self withIntroModalOnFirstLaunch:YES];
[[Mighty sharedInstance] makeRibbonHidden:NO withAnimation:YES];
@interface HomeViewController : UIViewController <MightyDelegate>
[Mighty sharedInstance].mightyDelegate = self;
- (void)mightyDidRecordSuccessfulTransaction:(SKPaymentTransaction*)transaction;
Mighty 包含公共方法,允许您:
+ (Mighty*)sharedInstance; 返回一个共享实例。
返回值
+ (Mighty)initWithAuthToken:(NSString)token
使用 MightyIO 登录。登录此方法将根据 bundleIdentifier 返回您的游戏信息以及与该游戏关联的 Mighty 物品。
参数
示例
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[Mighty initWithAuthToken:@"authtoken"];
// Override point for customization after application launch.
return YES;
}
-(void)makeRibbonWithFrame:(CGRect)frame inViewController:(UIViewController*)viewController withIntroModalOnFirstLaunch:(BOOL)modal; 这是一个将SuperMighty Ribbon放置在指定中心点的方法。只有当在您的SuperMighty帐户中创建了有效的游戏和物品时,Ribbon才会显示。该方法还将在部署到App Store时根据活动状态显示/隐藏Ribbon。在物品处于开发阶段时,只要存在有效的物品/游戏,Ribbon应始终显示。
参数
示例
- (void)viewDidLoad
{
[[Mighty sharedInstance] makeRibbonWithCenter:CGPointMake(260, 45) inViewController:self withIntroModalOnFirstLaunch:YES];
}
-(void)makeRibbonWithIBOutlet:(UIButton*)button inViewController:(UIViewController*)viewController withIntroModalOnFirstLaunch:(BOOL)modal; 此方法允许您手动将SuperMighty ribbon资产放置在您的视图中,然后将其作为UIButton传递给SuperMighty。SuperMighty将为其添加一个目标,在控制事件UIControlEventTouchUpInside时启动SuperMighty。此方法还将在部署到App Store时根据活动状态显示/隐藏Ribbon。在物品处于开发阶段时,只要存在有效的物品/游戏,Ribbon应始终显示。需要注意的是,此方法将覆盖您的IBOutlet图像属性,以当前的MightyIO品牌为准。
参数
示例
- (void)viewDidLoad
{
[[Mighty sharedInstance] makeRibbonWithIBOutlet:smRibbonOutlet inViewController:self withIntroModalOnFirstLaunch:YES];
}
-(void)makeRibbonHidden:(BOOL)hidden withAnimation:(BOOL)animate; 允许您根据玩家在游戏中的位置显示或隐藏Ribbon。
参数
示例
- (IBAction)showRibbon:(id)sender
{
[[Mighty sharedInstance] makeRibbonHidden:NO withAnimation:YES];
}
Mighty代理提供的方法允许您在代码中响应当前MightyIO操作,例如:加载/打开/关闭弹出商店和完成购买。
-(void)mightyDidRecordSuccessfulTransaction:(SKPaymentTransaction*)transaction; 当玩家在Mighty弹出商店内完成购买时,将触发此代理函数,返回玩家事务的实例。请在以下代理方法中放置您的代码来解锁物品。
参数
示例
- (void)mightyDidRecordSuccessfulTransaction:(SKPaymentTransaction*)transaction
{
// You code to unlock the In-App Purchase
// Ideally this would be dynamic so that a new deployment will not be necessary to create a new MightyItem
}
-(void)mightyTransactionFailedWithError:(NSError*)error; 此代理方法可以用来通知玩家,他们的交易无法处理。
参数
示例
- (void)mightyTransactionFailedWithError:(NSError*)error
{
UIAlertView *purchaseError = [[UIAlertView alloc] initWithTitle:@"Purchase Error" message:@"There was an error processing their purchase." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
[purchaseError show];
}
-(void)mightyFinishedLoadingWithActiveCampaign:(BOOL)hasCampaign; 当您的游戏加载时,MightyIO会检查是否有与您的Bundle Identifier匹配的游戏MightyItem存在。这时将触发此代理方法。
参数
-(void)mightyModalOpen; 当用户点击Ribbon并打开Mighty弹出商店时,将触发此代理方法。
示例
- (void)mightyModalOpen
{
//Pause game play
}
-(void)mightyModalClose; 当玩家关闭Mighty弹出商店时,将触发此代理方法。
示例
- (void)mightyModalClosed
{
//Resume game play
}
使用StackEdit编写。