phizclip-ios-demo/FinDemo/功能演示/5.代理方法/FinDelegateViewController.m

120 lines
3.4 KiB
Objective-C
Raw Normal View History

2023-05-31 11:00:11 +08:00
//
// FinDelegateViewController.m
// FinDemo
//
// Created by 胡健辉 on 2023/5/30.
//
#import "FinDelegateViewController.h"
#import <FinApplet/FinApplet.h>
@interface FinDelegateViewController ()<FATAppletLifeCycleDelegate>
@end
@implementation FinDelegateViewController
- (instancetype)init {
if (self = [super init]) {
//设置FATAppletLifeCycleDelegate代理
[FATClient sharedClient].lifeCycleDelegate = self;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.whiteColor;
UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 300, 40)];
[button setTitle: NSLocalizedString(@"打开小程序", nil) forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.center = self.view.center;
}
- (void)click {
FATAppletRequest *request = [[FATAppletRequest alloc] init];
request.appletId = @"5f72e3559a6a7900019b5baa";//微信官方小程序
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:self completion:nil closeCompletion:nil];
}
#pragma mark 小程序生命周期 ------------------------------
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo didOpenCompletion:(NSError *)error {
NSLog(@"小程序打开完成的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo didCloseCompletion:(NSError *)error {
NSLog(@"小程序关闭完成的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo initCompletion:(NSError *)error {
NSLog(@"小程序初始化完成");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo didActive:(NSError *)error {
NSLog(@"小程序进入活跃状态的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo resignActive:(NSError *)error {
NSLog(@"小程序进入非活跃状态的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo didFail:(NSError *)error {
NSLog(@"小程序出错的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
/**
@param appletInfo info
@param error
*/
- (void)appletInfo:(FATAppletInfo *)appletInfo dealloc:(NSError *)error {
NSLog(@"小程序被销毁的事件");
NSLog(@"%@", NSStringFromSelector(_cmd));
}
2023-06-01 15:26:07 +08:00
- (void)dealloc {
[FATClient sharedClient].lifeCycleDelegate = nil;
}
2023-05-31 11:00:11 +08:00
@end