Skip to content

Commit 029b2bb

Browse files
PRLsirliupr
authored andcommitted
[APNS上报 也放到js里]
1 parent d810ef2 commit 029b2bb

File tree

6 files changed

+55
-31
lines changed

6 files changed

+55
-31
lines changed

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class App extends React.Component {
5252
}
5353

5454
componentDidMount() {
55-
JPush.init({"appKey":"129c21dc4cb5e6f6de194003","channel":"dev","production":1});
55+
JPush.init({"appKey":"02c7f79c9248ecadf25140f7","channel":"dev","production":1});
5656
//连接状态
5757
this.connectListener = result => {
5858
console.log("connectListener:" + JSON.stringify(result))

example/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ PODS:
1111
- DoubleConversion
1212
- glog
1313
- glog (0.3.5)
14-
- JCore (1.9.2):
14+
- JCore (1.9.5):
1515
- React
16-
- JPush (2.8.3):
16+
- JPush (2.8.8):
1717
- React
1818
- React (0.60.5):
1919
- React-Core (= 0.60.5)
@@ -167,8 +167,8 @@ SPEC CHECKSUMS:
167167
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
168168
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
169169
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
170-
JCore: 82ea6d26c4c30dde4ec9553b0c8fe87eebfa5142
171-
JPush: 5941cabd5ffdd5d3186759f089acd2fcdd59905e
170+
JCore: 7e9473558d4e2e80fc2204610035051eefd093fd
171+
JPush: 04e6b729162edf8ab9d7f4e3f578d3fbdd591d26
172172
React: 53c53c4d99097af47cf60594b8706b4e3321e722
173173
React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64
174174
React-cxxreact: 8384287780c4999351ad9b6e7a149d9ed10a2395

example/ios/example/AppDelegate.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ @implementation AppDelegate
2121

2222
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
2323
// JPush初始化配置 可以延时初始化 不再强制在此初始化,在js里可以直接调用init
24-
// [JPUSHService setupWithOption:launchOptions appKey:@"129c21dc4cb5e6f6de194003"
24+
// [JPUSHService setupWithOption:launchOptions appKey:@"02c7f79c9248ecadf25140f7"
2525
// channel:@"dev" apsForProduction:YES];
26-
// APNS
27-
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
28-
if (@available(iOS 12.0, *)) {
29-
entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings;
30-
}
31-
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
32-
[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
33-
// 自定义消息
34-
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
35-
[defaultCenter addObserver:self selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
36-
// 地理围栏
37-
[JPUSHService registerLbsGeofenceDelegate:self withLaunchOptions:launchOptions];
26+
// // APNS
27+
// JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
28+
// if (@available(iOS 12.0, *)) {
29+
// entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings;
30+
// }
31+
// [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
32+
// [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
33+
// // 自定义消息
34+
// NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
35+
// [defaultCenter addObserver:self selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
36+
// // 地理围栏
37+
// [JPUSHService registerLbsGeofenceDelegate:self withLaunchOptions:launchOptions];
3838
// ReactNative环境配置
3939
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
4040
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge

example/ios/example/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
</dict>
4040
<key>NSLocationWhenInUseUsageDescription</key>
4141
<string></string>
42+
<key>UIBackgroundModes</key>
43+
<array>
44+
<string>remote-notification</string>
45+
</array>
4246
<key>UILaunchStoryboardName</key>
4347
<string>LaunchScreen</string>
4448
<key>UIRequiredDeviceCapabilities</key>

ios/RCTJPushModule/RCTJPushModule.m

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,35 @@ - (id)init
122122
RCT_EXPORT_METHOD(setupWithConfig:(NSDictionary *)params)
123123
{
124124
if (params[@"appKey"] && params[@"channel"] && params[@"production"]) {
125-
// JPush初始化配置
126-
NSMutableDictionary *launchOptions = [NSMutableDictionary dictionaryWithDictionary:self.bridge.launchOptions];
127-
[JPUSHService setupWithOption:launchOptions appKey:params[@"appKey"]
128-
channel:params[@"channel"] apsForProduction:[params[@"production"] boolValue]];
129-
}
130-
NSMutableArray *notificationList = [RCTJPushEventQueue sharedInstance]._notificationQueue;
131-
if(notificationList.count) {
132-
[self sendApnsNotificationEventByDictionary:notificationList[0]];
133-
}
134-
NSMutableArray *localNotificationList = [RCTJPushEventQueue sharedInstance]._localNotificationQueue;
135-
if(localNotificationList.count) {
136-
[self sendLocalNotificationEventByDictionary:localNotificationList[0]];
137-
}
125+
// JPush初始化配置
126+
NSMutableDictionary *launchOptions = [NSMutableDictionary dictionaryWithDictionary:self.bridge.launchOptions];
127+
[JPUSHService setupWithOption:launchOptions appKey:params[@"appKey"]
128+
channel:params[@"channel"] apsForProduction:[params[@"production"] boolValue]];
129+
130+
dispatch_async(dispatch_get_main_queue(), ^{
131+
// APNS
132+
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
133+
if (@available(iOS 12.0, *)) {
134+
entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings;
135+
}
136+
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self.bridge.delegate];
137+
[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
138+
// 自定义消息
139+
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
140+
[defaultCenter addObserver:self.bridge.delegate selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
141+
// 地理围栏
142+
[JPUSHService registerLbsGeofenceDelegate:self.bridge.delegate withLaunchOptions:launchOptions];
143+
});
144+
145+
NSMutableArray *notificationList = [RCTJPushEventQueue sharedInstance]._notificationQueue;
146+
if(notificationList.count) {
147+
[self sendApnsNotificationEventByDictionary:notificationList[0]];
148+
}
149+
NSMutableArray *localNotificationList = [RCTJPushEventQueue sharedInstance]._localNotificationQueue;
150+
if(localNotificationList.count) {
151+
[self sendLocalNotificationEventByDictionary:localNotificationList[0]];
152+
}
153+
}
138154
}
139155

140156
RCT_EXPORT_METHOD(loadJS)

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
"types": "index.d.ts",
77
"license": "ISC",
88
"author": "wicked.tc130",
9+
<<<<<<< HEAD
910
"version": "2.9.2",
11+
=======
12+
"version": "2.8.9",
13+
>>>>>>> fa7b3b0 ([APNS上报 也放到js里])
1014
"repository": {
1115
"type": "git",
1216
"url": "https://github.com/jpush/jpush-react-native"

0 commit comments

Comments
 (0)