Skip to content

Commit 39bd1b7

Browse files
Gen LiuGen Liu
authored andcommitted
Merge branch 'ios'
2 parents 3acc11e + 9a66efe commit 39bd1b7

16 files changed

+596
-8
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.project
2-
.tmp/
1+
.*
32
node_modules/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
腾讯信鸽推送服务:http://xg.qq.com/
66

7-
信鸽 SDK 版本:2.40
7+
信鸽 Android SDK 版本:2.40
8+
9+
信鸽 iOS SDK 版本:2.4.0
810

911
Cordova 版本:3.x / 4.x / 5.x
1012

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xgpush-cordova",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"description": "腾讯信鸽推送服务:http://xg.qq.com/",
55
"main": "index.js",
66
"dependencies": {

plugin.xml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<plugin xmlns:android="http://schemas.android.com/apk/res/android"
3-
id="com.eteng.push.xgpush"
4-
version="0.1.3">
3+
id="cordova-plugin-xgpush"
4+
version="0.2.0">
55

66
<name>xgpush-cordova</name>
77
<description>Tencent XGPush Plugin</description>
@@ -147,6 +147,53 @@
147147

148148
</platform>
149149

150+
<!-- ios -->
151+
<platform name="ios">
152+
153+
<config-file target="config.xml" parent="/*">
154+
<feature name="XGPush">
155+
<param name="ios-package" value="CDVXGPushPlugin"/>
156+
<param name="onload" value="true"/>
157+
</feature>
158+
</config-file>
159+
160+
<config-file target="*-Info.plist" parent="XGPushMeta">
161+
<dict>
162+
<key>AccessID</key>
163+
<integer>$ACCESS_ID</integer>
164+
<key>AccessKey</key>
165+
<string>$ACCESS_KEY</string>
166+
</dict>
167+
</config-file>
168+
169+
<!-- Tencent XGPush SDK -->
170+
<header-file src="src/ios/2.4.0/XGPush.h" />
171+
<header-file src="src/ios/2.4.0/XGSetting.h" />
172+
<source-file src="src/ios/2.4.0/libXG-SDK.a" framework="true" />
173+
174+
<!-- Cordova Plugin -->
175+
<header-file src="src/ios/AppDelegate+CDVXGPush.h" />
176+
<source-file src="src/ios/AppDelegate+CDVXGPush.m" />
177+
178+
<header-file src="src/ios/CDVXGPushPlugin.h" />
179+
<source-file src="src/ios/CDVXGPushPlugin.m" />
180+
181+
<header-file src="src/ios/CDVXGPushUtil.h" />
182+
<source-file src="src/ios/CDVXGPushUtil.m" />
183+
184+
<header-file src="src/ios/CDVRegisterNotification.h" />
185+
<source-file src="src/ios/CDVRegisterNotification.m" />
186+
187+
<!-- Dependencies -->
188+
<framework src="libz.dylib" />
189+
<framework src="libsqlite3.dylib" />
190+
<framework src="CFNetwork.framework" />
191+
<framework src="SystemConfiguration.framework" />
192+
<framework src="CoreTelephony.framework" />
193+
<framework src="Security.framework" />
194+
195+
</platform>
196+
150197
<dependency id="es6-promise-plugin" url="https://github.com/vstirbu/PromisesPlugin.git"></dependency>
151198

152199
</plugin>

src/android/v2/XGCordova.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import android.util.Log;
1111

1212
public class XGCordova extends XGPushPlugin {
13-
13+
1414
private static final String TAG = "XGCordovaPlugin";
1515
private ReceiverManager manager = new ReceiverManager();
1616

@@ -38,7 +38,7 @@ protected boolean unregisterPush(Context context, CallbackContext callback) {
3838

3939
@Override
4040
protected boolean addListener(Context context, CallbackContext callback) {
41-
return manager.registerReceiver(context, callback);
41+
return manager.registerReceiver(context, callback);
4242
}
4343

4444
}

src/ios/2.4.0/XGPush.h

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
//
2+
// XGPush.h
3+
// XG-SDK
4+
//
5+
// Created by xiangchen on 13-10-18.
6+
// Copyright (c) 2013年 mta. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
11+
12+
#define XG_SDK_VERSION @"2.4.0"
13+
14+
@interface XGPush : NSObject
15+
16+
/**
17+
* 初始化信鸽
18+
* @param appId - 通过前台申请的应用ID
19+
* @param appKey - 通过前台申请的appKey
20+
* @return none
21+
*/
22+
+(void)startApp:(uint32_t)appId appKey:(NSString *)appKey;
23+
24+
/**
25+
* 如果注销过信鸽,需要再次注册push服务前的准备
26+
* @param successCallback 初始化之后的回调,如果需要即刻恢复push服务,registerPush在此回调中调用
27+
* @return none
28+
*/
29+
+(void)initForReregister:(void (^)(void)) successCallback;
30+
31+
/**
32+
* 判断当前是否是已注销状态
33+
* @param none
34+
* @return none
35+
*/
36+
+(BOOL)isUnRegisterStatus;
37+
38+
/**
39+
* 设置设备的帐号 (在初始化信鸽后,注册设备之前调用。account本质上是registerDevice的一个参数)
40+
* @param account - 帐号名(长度为2个字节以上,不要使用"test","123456"这种过于简单的字符串)
41+
* @return none
42+
*/
43+
+(void)setAccount:(NSString *)account;
44+
45+
/**
46+
* 注册设备
47+
* @param deviceToken - 通过app delegate的didRegisterForRemoteNotificationsWithDeviceToken回调的获取
48+
* @return 获取的deviceToken字符串
49+
*/
50+
+(NSString *)registerDevice:(NSData *)deviceToken;
51+
52+
//注册设备,支持回调函数版本
53+
+(NSString *)registerDevice:(NSData *)deviceToken successCallback:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback;
54+
55+
//注册设备,支持字符串deviceToken版本
56+
+(NSString *)registerDeviceStr:(NSString *)deviceToken;
57+
58+
/**
59+
* 注销设备,设备不再进行推送
60+
* @param none
61+
* @return none
62+
*/
63+
+(void)unRegisterDevice;
64+
65+
//注销设备,支持回调版本
66+
+(void)unRegisterDevice:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback;
67+
68+
/**
69+
* 设置tag
70+
* @param tag - 需要设置的tag
71+
* @return none
72+
*/
73+
+(void)setTag:(NSString *)tag;
74+
75+
//设置tag,支持回调版本
76+
+(void)setTag:(NSString *)tag successCallback:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback;
77+
78+
/**
79+
* 删除tag
80+
* @param tag - 需要删除的tag
81+
* @return none
82+
*/
83+
+(void)delTag:(NSString *)tag;
84+
85+
//删除tag,支持回调版本
86+
+(void)delTag:(NSString *)tag successCallback:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback;
87+
88+
/**
89+
* 在didReceiveRemoteNotification中调用,用于推送反馈。(app在运行时)
90+
* @param userInfo 苹果apns的推送信息
91+
* @return none
92+
*/
93+
+(void)handleReceiveNotification:(NSDictionary *)userInfo;
94+
95+
//信鸽Pro专用接口
96+
+(void)handleReceiveNotification:(NSDictionary *)userInfo completion:(void (^)(void)) completion;
97+
98+
//推送反馈(app在运行时),支持回调版本
99+
+(void)handleReceiveNotification:(NSDictionary *)userInfo successCallback:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback completion:(void (^)(void)) completion;
100+
101+
/**
102+
* 在didFinishLaunchingWithOptions中调用,用于推送反馈.(app没有运行时,点击推送启动时)
103+
* @param userInfo
104+
* @return none
105+
*/
106+
+(void)handleLaunching:(NSDictionary *)launchOptions;
107+
108+
//推送反馈.(app没有运行时,点击推送启动时),支持回调版本
109+
+(void)handleLaunching:(NSDictionary *)launchOptions successCallback:(void (^)(void)) successCallback errorCallback:(void (^)(void)) errorCallback;
110+
111+
/**
112+
* 获取userInfo里的bid信息(bid:信鸽的推送消息id)
113+
* @param userInfo 苹果apns的推送信息
114+
* @return none
115+
*/
116+
+(NSString *)getBid:(NSDictionary *)userInfo;
117+
118+
/**
119+
* deviceToken类型转换
120+
* @param deviceToken NSData格式的deviceToken
121+
* @return none
122+
*/
123+
+(NSString *)getDeviceToken:(NSData *)deviceToken;
124+
125+
/**
126+
* 获取本地缓存的deviceToken
127+
* @param none
128+
* @return 信鸽启动时填入的的accessID
129+
*/
130+
+(uint32_t)getAccessID;
131+
132+
/**************************
133+
以下是本地推送相关
134+
**************************/
135+
136+
/**
137+
* 本地推送,最多支持64个
138+
* @param fireDate 本地推送触发的时间
139+
* @param alertBody 推送的内容
140+
* @param badge 角标的数字。如果不改变,则传递 -1
141+
* @param alertAction 替换弹框的按钮文字内容(默认为"启动")
142+
* @param userInfo 自定义参数,可以用来标识推送和增加附加信息
143+
* @return none
144+
*/
145+
+(void)localNotification:(NSDate *)fireDate alertBody:(NSString *)alertBody badge:(int)badge alertAction:(NSString *)alertAction userInfo:(NSDictionary *)userInfo;
146+
147+
/**
148+
* 本地推送在前台推送。默认App在前台运行时不会进行弹窗,通过此接口可实现指定的推送弹窗。
149+
* @param notification 本地推送对象
150+
* @param userInfoKey 本地推送的标识Key
151+
* @param userInfoValue 本地推送的标识Key对应的值
152+
* @return none
153+
*/
154+
+(void)localNotificationAtFrontEnd:(UILocalNotification *)notification userInfoKey:(NSString *)userInfoKey userInfoValue:(NSString *)userInfoValue;
155+
156+
/**
157+
* 删除本地推送,方法1
158+
* @param userInfoKey 本地推送的标识Key
159+
* @param userInfoValue 本地推送的标识Key对应的值
160+
* @return none
161+
*/
162+
+(void)delLocalNotification:(NSString *)userInfoKey userInfoValue:(NSString *)userInfoValue;
163+
164+
/**
165+
* 删除本地推送,方法2
166+
* @param myUILocalNotification 本地推送对象
167+
* @return none
168+
*/
169+
+(void)delLocalNotification:(UILocalNotification *)myUILocalNotification;
170+
171+
/**
172+
* 清除所有本地推送对象
173+
* @param none
174+
* @return none
175+
*/
176+
+(void)clearLocalNotifications;
177+
178+
@end

src/ios/2.4.0/XGSetting.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// XGSetting.h
3+
// XG-SDK
4+
//
5+
// Created by xiangchen on 29/08/14.
6+
// Copyright (c) 2014 mta. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface XGSetting : NSObject
12+
13+
@property (nonatomic,retain) NSString* Channel;
14+
@property (nonatomic,retain) NSString* GameServer;
15+
16+
+(id)getInstance;
17+
@end

src/ios/2.4.0/libXG-SDK.a

5.08 MB
Binary file not shown.

src/ios/AppDelegate+CDVXGPush.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import "AppDelegate.h"
2+
#import <Foundation/Foundation.h>
3+
4+
@interface AppDelegate (CDVXGPush)
5+
@end

src/ios/AppDelegate+CDVXGPush.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#import "AppDelegate+CDVXGPush.h"
2+
3+
@implementation AppDelegate (CDVXGPush)
4+
5+
/**
6+
* 追加推送事件
7+
*/
8+
- (void) application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo {
9+
NSLog(@"[AppDelegate] receive remote notification");
10+
[[NSNotificationCenter defaultCenter] postNotificationName: @"receivenotification" object:userInfo];
11+
}
12+
13+
@end

0 commit comments

Comments
 (0)