智莺生活APP的阿里百川 Flutter 插件
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
3 лет назад
3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #import "FlutterAlibcPlugin.h"
  2. #import "FlutterAlibcHandle.h"
  3. //#import <AlibcTradeSDK/AlibcTradeSDK.h>
  4. #import <AlibcTradeUltimateSDK/AlibcTradeUltimateSDK.h>
  5. @interface FlutterAlibcPlugin()
  6. //一个handle服务
  7. @property(nonatomic,strong)FlutterAlibcHandle *handler;
  8. //一个service服务
  9. @end
  10. @implementation FlutterAlibcPlugin
  11. + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  12. FlutterMethodChannel* channel = [FlutterMethodChannel
  13. methodChannelWithName:@"flutter_alibc"
  14. binaryMessenger:[registrar messenger]];
  15. FlutterAlibcPlugin* instance = [[FlutterAlibcPlugin alloc] initWithRegistrar:registrar methodChannel:channel];
  16. [registrar addMethodCallDelegate:instance channel:channel];
  17. [registrar addApplicationDelegate:instance];
  18. }
  19. - (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel{
  20. self = [super init];
  21. if (self) {
  22. self.handler = [[FlutterAlibcHandle alloc]init];
  23. }
  24. return self;
  25. }
  26. - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  27. if ([@"getPlatformVersion" isEqualToString:call.method]) {
  28. result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  29. }else if ([@"initAlibc" isEqualToString:call.method]){
  30. [_handler initAlibc:call result:result];
  31. }else if([@"loginTaoBao" isEqualToString:call.method]){
  32. [_handler loginTaoBao:call result:result];
  33. }else if([@"taoKeLogin" isEqualToString:call.method]){
  34. [_handler taoKeLogin:call result:result];
  35. }else if([@"loginOut" isEqualToString:call.method]){
  36. [_handler loginOut];
  37. }else if([@"openByUrl" isEqualToString:call.method]){
  38. [_handler openByUrl:call result:result];
  39. }else if([@"openItemDetail" isEqualToString:call.method]){
  40. [_handler openItemDetail:call result:result];
  41. }else if([@"openShop" isEqualToString:call.method]){
  42. [_handler openShop:call result:result];
  43. }else if([@"openCart" isEqualToString:call.method]){
  44. [_handler openCart:call result:result];
  45. }else if([@"syncForTaoke" isEqualToString:call.method]){
  46. [_handler syncForTaoke:call result:result];
  47. }else if([@"useAlipayNative" isEqualToString:call.method]){
  48. [_handler useAlipayNative:call result:result];
  49. }else if([@"getUdid" isEqualToString:call.method]){
  50. [_handler getUdid:call result:result];
  51. }else {
  52. result(FlutterMethodNotImplemented);
  53. }
  54. }
  55. #pragma mark -- 下面两个为百川处理应用跳转
  56. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
  57. // 如果百川处理过会返回YES
  58. //if (![[AlibcTradeSDK sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) {
  59. // return YES;
  60. //}
  61. return YES;
  62. }
  63. //IOS9.0 系统新的处理openURL 的API
  64. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  65. if (@available(iOS 9.0, *)) {
  66. //__unused BOOL isHandledByALBBSDK=[[AlibcTradeSDK sharedInstance] application:application openURL:url options:options];
  67. //return isHandledByALBBSDK;
  68. __unused BOOL isHandledByALBBSDK=[[AlibcTradeUltimateSDK sharedInstance] application:application openURL:url options:options];
  69. return isHandledByALBBSDK;
  70. } else {
  71. // Fallback on earlier versions
  72. }//处理其他app跳转到自己的app,如果百川处理过会返回YES
  73. return NO;
  74. }
  75. @end