@@ -14,7 +14,7 @@ @interface CYShare ()
14
14
15
15
@implementation CYShare
16
16
17
- #if CY_SHARE_WECHAT_ENABLED
17
+ #if CY_WECHAT_ENABLED
18
18
+ (void )registerWechatAppId : (NSString *)appId {
19
19
[[CYWechat sharedInstance ] registerAppId: appId];
20
20
}
@@ -23,26 +23,20 @@ + (void)registerWechatAppKey:(NSString *)appKey {
23
23
[[CYWechat sharedInstance ] registerAppKey: appKey];
24
24
}
25
25
26
- + (void )shareToWechat : (CYShareModel *)model
27
- scene : (CYWechatScene)scene
28
- callback : (CYShareCallback)callback {
26
+ + (void )shareToWechat : (CYShareModel *)model scene : (CYWechatScene)scene callback : (CYShareCallback)callback {
29
27
30
28
[[CYWechat sharedInstance ] share: model
31
29
to: scene
32
30
callback: callback];
33
31
}
34
32
35
- + (void )shareToWechat : (CYShareModel *)model
36
- presentActionSheetFrom : (UIViewController *)viewController
37
- callback : (CYShareCallback)callback {
33
+ + (void )shareToWechat : (CYShareModel *)model fromViewController : (UIViewController *)viewController callback : (CYShareCallback)callback {
38
34
39
- [[CYWechat sharedInstance ] share: model
40
- presentActionSheetFrom: viewController
41
- callback: callback];
35
+ [[CYWechat sharedInstance ] share: model fromViewController: viewController callback: callback];
42
36
}
43
37
#endif
44
38
45
- #if CY_SHARE_QQ_ENABLED
39
+ #if CY_QQ_ENABLED
46
40
+ (void )registerQQAppId : (NSString *)appId {
47
41
[[CYQQ sharedInstance ] registerAppId: appId];
48
42
}
@@ -51,25 +45,17 @@ + (void)registerQQAppKey:(NSString *)appKey {
51
45
[[CYQQ sharedInstance ] registerAppKey: appKey];
52
46
}
53
47
54
- + (void )shareToQQ : (CYShareModel *)model
55
- ctrlFlag : (CYQQAPICtrlFlag)flag
56
- callback : (CYShareCallback)callback {
57
- [[CYQQ sharedInstance ] share: model
58
- to: flag
59
- callback: callback];
48
+ + (void )shareToQQ : (CYShareModel *)model ctrlFlag : (CYQQAPICtrlFlag)flag callback : (CYShareCallback)callback {
49
+ [[CYQQ sharedInstance ] share: model to: flag callback: callback];
60
50
}
61
51
62
- + (void )shareToQQ : (CYShareModel *)model
63
- presentActionSheetFrom : (UIViewController *)viewController
64
- callback : (CYShareCallback)callback {
52
+ + (void )shareToQQ : (CYShareModel *)model fromViewController : (UIViewController *)viewController callback : (CYShareCallback)callback {
65
53
66
- [[CYQQ sharedInstance ] share: model
67
- presentActionSheetFrom: viewController
68
- callback: callback];
54
+ [[CYQQ sharedInstance ] share: model fromViewController: viewController callback: callback];
69
55
}
70
56
#endif
71
57
72
- #if CY_SHARE_SINA_WEIBO_ENABLED
58
+ #if CY_SINA_WEIBO_ENABLED
73
59
+ (void )registerWeiboAppKey : (NSString *)appKey {
74
60
[[CYSinaWeibo sharedInstance ] registerAppKey: appKey];
75
61
}
@@ -83,40 +69,84 @@ + (void)shareToWeibo:(CYShareModel *)model
83
69
84
70
#if CY_SHARE_APPLE_ACTIVITY_ENABLED
85
71
86
- + (void )shareByAppleActivity : (CYShareModel *)model
87
- presentFrom : (UIViewController *)viewController
88
- callback : (CYShareCallback)callback {
89
- [[CYAppleActivity sharedInstance ] share: model
90
- presentFrom: viewController
91
- callback: callback];
72
+ + (void )shareByAppleActivity : (CYShareModel *)model fromViewController : (UIViewController *)viewController callback : (CYShareCallback)callback {
73
+ [[CYAppleActivity sharedInstance ] share: model fromViewController: viewController callback: callback];
92
74
}
93
75
94
76
#endif
95
77
96
78
#if CY_SHARE_SMS_ENABLED
97
79
98
- + (void )shareBySMS : (CYShareModel *)model
99
- to : (NSArray *)mobiles
100
- presentFrom : (UIViewController *)viewController
101
- callback : (CYShareCallback)callback {
102
- [[CYSMS sharedInstance ] share: model
103
- toUsers: mobiles
104
- presentFrom: viewController
105
- callback: callback];
80
+ + (void )shareBySMS : (CYShareModel *)model to : (NSArray *)mobiles fromViewController : (UIViewController *)viewController callback : (CYShareCallback)callback {
81
+ [[CYSMS sharedInstance ] share: model toMobiles: mobiles fromViewController: viewController callback: callback];
82
+ }
83
+
84
+ #endif
85
+
86
+ #if CY_FACEBOOK_ENABLED
87
+
88
+ + (void )shareToFacebook : (CYShareModel *)model fromViewController : (UIViewController *)viewController callback : (CYShareCallback)callback {
89
+ [[CYFacebook sharedInstance ] share: model fromViewController: viewController callback: callback];
90
+ }
91
+
92
+ #endif
93
+
94
+ #pragma mark - handle open url
95
+ // 以下几个方法需要在AppDelegate对应的方法中进行调用,并且必须实现这些方法
96
+ + (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions {
97
+ BOOL result = NO ;
98
+ #if CY_WECHAT_ENABLED
99
+ result = [[CYWechat sharedInstance ] application: application didFinishLaunchingWithOptions: launchOptions];
100
+ #endif
101
+ #if CY_QQ_ENABLED
102
+ result = (result || [[CYQQ sharedInstance ] application: application didFinishLaunchingWithOptions: launchOptions]);
103
+ #endif
104
+ #if CY_SINA_WEIBO_ENABLED
105
+ result = (result || [[CYSinaWeibo sharedInstance ] application: application didFinishLaunchingWithOptions: launchOptions]);
106
+ #endif
107
+ #if CY_FACEBOOK_ENABLED
108
+ result = (result || [[CYFacebook sharedInstance ] application: application didFinishLaunchingWithOptions: launchOptions]);
109
+ #endif
110
+ return result;
106
111
}
107
112
113
+ + (BOOL )application : (UIApplication *)application
114
+ openURL : (NSURL *)url
115
+ sourceApplication : (NSString *)sourceApplication
116
+ annotation : (id )annotation {
117
+
118
+ BOOL result = NO ;
119
+ #if CY_WECHAT_ENABLED
120
+ result = [[CYWechat sharedInstance ] application: application openURL: url sourceApplication: sourceApplication annotation: annotation];
121
+ #endif
122
+ #if CY_QQ_ENABLED
123
+ result = (result || [[CYQQ sharedInstance ] application: application openURL: url sourceApplication: sourceApplication annotation: annotation]);
108
124
#endif
125
+ #if CY_SINA_WEIBO_ENABLED
126
+ result = (result || [[CYSinaWeibo sharedInstance ] application: application openURL: url sourceApplication: sourceApplication annotation: annotation]);
127
+ #endif
128
+ #if CY_FACEBOOK_ENABLED
129
+ result = (result || [[CYFacebook sharedInstance ] application: application openURL: url sourceApplication: sourceApplication annotation: annotation]);
130
+ #endif
131
+ return result;
132
+ }
133
+
134
+ + (BOOL )application : (UIApplication *)application
135
+ openURL : (NSURL *)url
136
+ options : (NSDictionary <UIApplicationOpenURLOptionsKey,id> *)options {
109
137
110
- + (BOOL )handleOpenURL : (NSURL *)URL {
111
138
BOOL result = NO ;
112
- #if CY_SHARE_WECHAT_ENABLED
113
- result = [[CYWechat sharedInstance ] handleOpenURL: URL];
139
+ #if CY_WECHAT_ENABLED
140
+ result = [[CYWechat sharedInstance ] application: application openURL: url options: options];
141
+ #endif
142
+ #if CY_QQ_ENABLED
143
+ result = (result || [[CYQQ sharedInstance ] application: application openURL: url options: options]);
114
144
#endif
115
- #if CY_SHARE_QQ_ENABLED
116
- result = (result || [[CYQQ sharedInstance ] handleOpenURL: URL ]);
145
+ #if CY_SINA_WEIBO_ENABLED
146
+ result = (result || [[CYSinaWeibo sharedInstance ] application: application openURL: url options: options ]);
117
147
#endif
118
- #if CY_SHARE_SINA_WEIBO_ENABLED
119
- result = (result || [[CYSinaWeibo sharedInstance ] handleOpenURL: URL ]);
148
+ #if CY_FACEBOOK_ENABLED
149
+ result = (result || [[CYFacebook sharedInstance ] application: application openURL: url options: options ]);
120
150
#endif
121
151
return result;
122
152
}
0 commit comments