diff --git a/demo.xcodeproj/project.pbxproj b/demo.xcodeproj/project.pbxproj index 9e07453..7ec1768 100644 --- a/demo.xcodeproj/project.pbxproj +++ b/demo.xcodeproj/project.pbxproj @@ -7,13 +7,15 @@ objects = { /* Begin PBXBuildFile section */ - 8A8D5069EEC4CE9564C7B391 /* libPods-demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28A582EE796CD12C1FF4F5DB /* libPods-demo.a */; }; 9DD565BE23EC45080011FC4A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565BD23EC45080011FC4A /* AppDelegate.m */; }; 9DD565C423EC45080011FC4A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565C323EC45080011FC4A /* ViewController.m */; }; 9DD565C923EC450A0011FC4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565C823EC450A0011FC4A /* Assets.xcassets */; }; 9DD565CC23EC450A0011FC4A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */; }; 9DD565CF23EC450A0011FC4A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565CE23EC450A0011FC4A /* main.m */; }; + A823321F258C3B7000C1B2D5 /* FINDemoClientHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */; }; A863B745257A09A300959AA1 /* FINExtensionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A863B744257A09A300959AA1 /* FINExtensionHelper.m */; }; + A8BC097A258BA095001289A3 /* FINCustomMenuModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */; }; + FBF7F422A6EA50C856DB84F7 /* libPods-demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 28A582EE796CD12C1FF4F5DB /* libPods-demo.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,8 +30,12 @@ 9DD565CB23EC450A0011FC4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 9DD565CD23EC450A0011FC4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9DD565CE23EC450A0011FC4A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FINDemoClientHelper.m; sourceTree = ""; }; + A823321E258C3B7000C1B2D5 /* FINDemoClientHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINDemoClientHelper.h; sourceTree = ""; }; A863B743257A09A200959AA1 /* FINExtensionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINExtensionHelper.h; sourceTree = ""; }; A863B744257A09A300959AA1 /* FINExtensionHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FINExtensionHelper.m; sourceTree = ""; }; + A8BC0978258BA095001289A3 /* FINCustomMenuModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FINCustomMenuModel.h; sourceTree = ""; }; + A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FINCustomMenuModel.m; sourceTree = ""; }; FBEBA7E73B95B66C846E76FF /* Pods-demo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo.debug.xcconfig"; path = "Target Support Files/Pods-demo/Pods-demo.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -38,7 +44,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8A8D5069EEC4CE9564C7B391 /* libPods-demo.a in Frameworks */, + FBF7F422A6EA50C856DB84F7 /* libPods-demo.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -68,8 +74,12 @@ children = ( 9DD565BC23EC45080011FC4A /* AppDelegate.h */, 9DD565BD23EC45080011FC4A /* AppDelegate.m */, + A823321E258C3B7000C1B2D5 /* FINDemoClientHelper.h */, + A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */, A863B743257A09A200959AA1 /* FINExtensionHelper.h */, A863B744257A09A300959AA1 /* FINExtensionHelper.m */, + A8BC0978258BA095001289A3 /* FINCustomMenuModel.h */, + A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */, 9DD565C223EC45080011FC4A /* ViewController.h */, 9DD565C323EC45080011FC4A /* ViewController.m */, 9DD565C823EC450A0011FC4A /* Assets.xcassets */, @@ -211,6 +221,8 @@ buildActionMask = 2147483647; files = ( 9DD565C423EC45080011FC4A /* ViewController.m in Sources */, + A823321F258C3B7000C1B2D5 /* FINDemoClientHelper.m in Sources */, + A8BC097A258BA095001289A3 /* FINCustomMenuModel.m in Sources */, A863B745257A09A300959AA1 /* FINExtensionHelper.m in Sources */, 9DD565BE23EC45080011FC4A /* AppDelegate.m in Sources */, 9DD565CF23EC450A0011FC4A /* main.m in Sources */, @@ -347,6 +359,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9QCKYFU5M4; + ENABLE_BITCODE = NO; INFOPLIST_FILE = demo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -365,6 +379,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9QCKYFU5M4; + ENABLE_BITCODE = NO; INFOPLIST_FILE = demo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/demo/AppDelegate.m b/demo/AppDelegate.m index 12ead9d..223ba56 100644 --- a/demo/AppDelegate.m +++ b/demo/AppDelegate.m @@ -9,6 +9,7 @@ #import "AppDelegate.h" #import "ViewController.h" #import "FINExtensionHelper.h" +#import "FINDemoClientHelper.h" #import @@ -29,6 +30,8 @@ [[FATClient sharedClient] initWithConfig:config error:nil]; + [FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper]; + [FINExtensionHelper registerCustomApis]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; diff --git a/demo/Assets.xcassets/Contents.json b/demo/Assets.xcassets/Contents.json index da4a164..73c0059 100644 --- a/demo/Assets.xcassets/Contents.json +++ b/demo/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json b/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json new file mode 100644 index 0000000..96dd923 --- /dev/null +++ b/demo/Assets.xcassets/minipro_list_collect.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "minipro_list_collect@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "minipro_list_collect@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png new file mode 100644 index 0000000..1b517c1 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@2x.png differ diff --git a/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png new file mode 100644 index 0000000..cf4dfb1 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_collect.imageset/minipro_list_collect@3x.png differ diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json b/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json new file mode 100644 index 0000000..4a2d688 --- /dev/null +++ b/demo/Assets.xcassets/minipro_list_service.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "minipro_list_service@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "minipro_list_service@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png new file mode 100644 index 0000000..5b5e785 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@2x.png differ diff --git a/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png new file mode 100644 index 0000000..bc2db40 Binary files /dev/null and b/demo/Assets.xcassets/minipro_list_service.imageset/minipro_list_service@3x.png differ diff --git a/demo/FINCustomMenuModel.h b/demo/FINCustomMenuModel.h new file mode 100644 index 0000000..194a608 --- /dev/null +++ b/demo/FINCustomMenuModel.h @@ -0,0 +1,18 @@ +// +// FINCustomMenuModel.h +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface FINCustomMenuModel : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/demo/FINCustomMenuModel.m b/demo/FINCustomMenuModel.m new file mode 100644 index 0000000..d8e884a --- /dev/null +++ b/demo/FINCustomMenuModel.m @@ -0,0 +1,24 @@ +// +// FINCustomMenuModel.m +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "FINCustomMenuModel.h" + +@implementation FINCustomMenuModel + +@synthesize menuId, menuIconImage, menuTitle; + +- (id)copyWithZone:(NSZone *)zone +{ + FINCustomMenuModel *model = [[FINCustomMenuModel allocWithZone:zone] init]; + model.menuId = self.menuId; + model.menuIconImage = self.menuIconImage; + model.menuTitle = self.menuTitle; + return model; +} + +@end diff --git a/demo/FINDemoClientHelper.h b/demo/FINDemoClientHelper.h new file mode 100644 index 0000000..9c77e58 --- /dev/null +++ b/demo/FINDemoClientHelper.h @@ -0,0 +1,17 @@ +// +// FINClientHelper.h +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import +#import + +@interface FINDemoClientHelper : NSObject + ++ (instancetype)sharedHelper; + +@end + diff --git a/demo/FINDemoClientHelper.m b/demo/FINDemoClientHelper.m new file mode 100644 index 0000000..3dea421 --- /dev/null +++ b/demo/FINDemoClientHelper.m @@ -0,0 +1,106 @@ +// +// FINClientHelper.m +// demo +// +// Created by Haley on 2020/12/17. +// Copyright © 2020 finogeeks. All rights reserved. +// + +#import "FINDemoClientHelper.h" +#import "FINCustomMenuModel.h" + +static FINDemoClientHelper *instance = nil; + +@implementation FINDemoClientHelper + ++ (instancetype)sharedHelper +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[[self class] alloc] init]; + }); + return instance; +} + +#pragma mark - FATAppletDelegate +- (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion +{ + NSLog(@"小程序信息:%@", contentInfo); + + // 1.如果你需要将小程序转发到自己app的聊天室,那么就根据contentInfo封装成自己IM消息,然后发送。 + + // 2.如果你需要将小程序转发到自己app的朋友圈,那么就根据contentInfo,组装信息发送给后台。 +} + +/// 小程序灰度扩展参数 +/// @param appletId 小程序id +- (NSDictionary *)grayExtensionWithAppletId:(NSString *)appletId +{ + if ([appletId isEqualToString:@"5facb3a52dcbff00017469bd"]) { + return @{@"phone":@(1234567890)}; + } + + if ([appletId isEqualToString:@"5fa214a29a6a7900019b5cc1"]) { + return @{@"token":@"xxxxxtoken"}; + } + + return @{@"key1":@"value1"}; +} + +#pragma mark - more menu +/// 更多按钮中自定义的菜单,会在页面弹出菜单时调用该api +/// @param appletInfo 小程序信息 +/// @param path 页面路径 +- (NSArray> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path +{ + NSString *appletId = appletInfo.appId; + if ([appletId isEqualToString:@"5facb3a52dcbff00017469bd"]) { + FINCustomMenuModel *favModel1 = [[FINCustomMenuModel alloc] init]; + favModel1.menuId = 1001; + favModel1.menuTitle = @"客服"; + favModel1.menuIconImage = [UIImage imageNamed:@"minipro_list_service"]; + + return @[favModel1]; + } + + if ([appletId isEqualToString:@"5fa214a29a6a7900019b5cc1"]) { + FINCustomMenuModel *favModel2 = [[FINCustomMenuModel alloc] init]; + favModel2.menuId = 1002; + favModel2.menuTitle = @"收藏"; + favModel2.menuIconImage = [UIImage imageNamed:@"minipro_list_collect"]; + + return @[favModel2]; + } + + FINCustomMenuModel *favModel1 = [[FINCustomMenuModel alloc] init]; + favModel1.menuId = 1001; + favModel1.menuTitle = @"客服"; + favModel1.menuIconImage = [UIImage imageNamed:@"minipro_list_service"]; + + FINCustomMenuModel *favModel2 = [[FINCustomMenuModel alloc] init]; + favModel2.menuId = 1002; + favModel2.menuTitle = @"收藏"; + favModel2.menuIconImage = [UIImage imageNamed:@"minipro_list_collect"]; + + return @[favModel1, favModel2]; +} + +/// 点击自定义菜单时,会触发的事件 +/// @param customMenu 自定义菜单对象 +/// @param appletInfo 小程序信息 +/// @param path 当前页面路径 +- (void)customMenu:(id)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path +{ + NSLog(@"自定义按钮被点击"); + if (customMenu.menuId == 1001) { + NSLog(@"客服按钮被点击"); + return; + } + + if (customMenu.menuId == 1002) { + NSLog(@"收藏按钮被点击"); + return; + } +} + +@end