Skip to content

Commit 3f121ce

Browse files
author
TC130精神扰乱装置
authored
Merge pull request #748 from jpush/dev
Android-处理setAlias问题,iOS-角标设置切换到主线程
2 parents 8c1b210 + 737e7c4 commit 3f121ce

File tree

8 files changed

+41
-26
lines changed

8 files changed

+41
-26
lines changed

android/src/main/java/cn/jiguang/plugins/push/helper/JPushHelper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,20 @@ public static WritableMap convertCustomMessage(CustomMessage customMessage) {
6363

6464
public static WritableMap convertJPushMessageToMap(int type, JPushMessage message) {
6565
WritableMap writableMap = Arguments.createMap();
66-
Set<String> tags = message.getTags();
67-
WritableArray tagsArray = Arguments.createArray();
68-
for (String tag : tags) {
69-
tagsArray.pushString(tag);
70-
}
66+
7167
writableMap.putInt(JConstants.CODE, message.getErrorCode());
7268
writableMap.putInt(JConstants.SEQUENCE, message.getSequence());
7369
switch (type) {
7470
case 1:
71+
Set<String> tags = message.getTags();
72+
WritableArray tagsArray = Arguments.createArray();
73+
if(tags==null || tags.isEmpty()){
74+
JLogger.d("tags is empty");
75+
}else {
76+
for (String tag : tags) {
77+
tagsArray.pushString(tag);
78+
}
79+
}
7580
writableMap.putArray(JConstants.TAGS, tagsArray);
7681
break;
7782
case 2:

example/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ export default class App extends React.Component {
127127
<Button title="setMobileNumber"
128128
onPress={() => JPush.setMobileNumber({mobileNumber: "13888888888"})}/>
129129
130+
//仅ios
131+
<Button title="setBadge"
132+
onPress={() => JPush.setBadge({"badge":1,"appBadge":1})}/>
133+
130134
<Button title="initCrashHandler"
131135
onPress={() => JPush.initCrashHandler()}/>
132136

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.5.0):
14+
- JCore (1.6.0):
1515
- React
16-
- JPush (2.6.1):
16+
- JPush (2.7.0):
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: 191e9e58a35fb87a7500ce7b0772ec83019eaa60
171-
JPush: 159215b5c435935bafc9b6b84611ebf4b141838a
170+
JCore: 54f06adbbb4a28c11e8bd2466d2a0656ec2f16c9
171+
JPush: 8fc065186252835feb4959274fc7bd140dfce2c4
172172
React: 53c53c4d99097af47cf60594b8706b4e3321e722
173173
React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64
174174
React-cxxreact: 8384287780c4999351ad9b6e7a149d9ed10a2395

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
1212
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1313
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
14-
D48F30ADA9DBC6D27534337B /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0177004FEECADA03DABFA376 /* libPods-example.a */; };
14+
363AE1E6DA5EE367B02FC146 /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DFA4ACDA756FDC209B6CB52 /* libPods-example.a */; };
1515
/* End PBXBuildFile section */
1616

1717
/* Begin PBXContainerItemProxy section */
@@ -35,22 +35,22 @@
3535
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
3636
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3737
00E356F21AD99517003FC87E /* exampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = exampleTests.m; sourceTree = "<group>"; };
38-
0177004FEECADA03DABFA376 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
38+
04CF78C193A0D587CF1E0CE0 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
3939
13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
4040
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = example/AppDelegate.h; sourceTree = "<group>"; };
4141
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = example/AppDelegate.m; sourceTree = "<group>"; };
4242
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
4343
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; };
4444
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; };
4545
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = example/main.m; sourceTree = "<group>"; };
46-
3A20B5BF7D863E9A31C10B5A /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = "<group>"; };
4746
5C0F2306237AEEFA0089C1F8 /* RCTJCoreModule.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTJCoreModule.xcodeproj; path = "../node_modules/jcore-react-native/ios/RCTJCoreModule.xcodeproj"; sourceTree = "<group>"; };
4847
5C0F230C237AEF120089C1F8 /* RCTJPushModule.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTJPushModule.xcodeproj; path = "../node_modules/jpush-react-native/ios/RCTJPushModule.xcodeproj"; sourceTree = "<group>"; };
4948
5C46FD022331F51D00F0198A /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
5049
5C46FD042331F52700F0198A /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
5150
5C46FD062331F53100F0198A /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
5251
5C46FD082331F53C00F0198A /* example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = example.entitlements; path = example/example.entitlements; sourceTree = "<group>"; };
53-
D92729E654196D4058224A10 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; };
52+
6DFA4ACDA756FDC209B6CB52 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
53+
AC77230391FFCA8A31383389 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = "<group>"; };
5454
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
5555
/* End PBXFileReference section */
5656

@@ -59,7 +59,7 @@
5959
isa = PBXFrameworksBuildPhase;
6060
buildActionMask = 2147483647;
6161
files = (
62-
D48F30ADA9DBC6D27534337B /* libPods-example.a in Frameworks */,
62+
363AE1E6DA5EE367B02FC146 /* libPods-example.a in Frameworks */,
6363
);
6464
runOnlyForDeploymentPostprocessing = 0;
6565
};
@@ -105,7 +105,7 @@
105105
5C46FD042331F52700F0198A /* libz.tbd */,
106106
5C46FD022331F51D00F0198A /* UserNotifications.framework */,
107107
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
108-
0177004FEECADA03DABFA376 /* libPods-example.a */,
108+
6DFA4ACDA756FDC209B6CB52 /* libPods-example.a */,
109109
);
110110
name = Frameworks;
111111
sourceTree = "<group>";
@@ -161,8 +161,8 @@
161161
B07776930455FAD2B06745D1 /* Pods */ = {
162162
isa = PBXGroup;
163163
children = (
164-
D92729E654196D4058224A10 /* Pods-example.debug.xcconfig */,
165-
3A20B5BF7D863E9A31C10B5A /* Pods-example.release.xcconfig */,
164+
AC77230391FFCA8A31383389 /* Pods-example.debug.xcconfig */,
165+
04CF78C193A0D587CF1E0CE0 /* Pods-example.release.xcconfig */,
166166
);
167167
path = Pods;
168168
sourceTree = "<group>";
@@ -174,7 +174,7 @@
174174
isa = PBXNativeTarget;
175175
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */;
176176
buildPhases = (
177-
657E00A7294BDD171FDBE5C9 /* [CP] Check Pods Manifest.lock */,
177+
9B88E118371F18FFFAE7D01F /* [CP] Check Pods Manifest.lock */,
178178
FD10A7F022414F080027D42C /* Start Packager */,
179179
13B07F871A680F5B00A75B9A /* Sources */,
180180
13B07F8C1A680F5B00A75B9A /* Frameworks */,
@@ -283,7 +283,7 @@
283283
shellPath = /bin/sh;
284284
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
285285
};
286-
657E00A7294BDD171FDBE5C9 /* [CP] Check Pods Manifest.lock */ = {
286+
9B88E118371F18FFFAE7D01F /* [CP] Check Pods Manifest.lock */ = {
287287
isa = PBXShellScriptBuildPhase;
288288
buildActionMask = 2147483647;
289289
files = (
@@ -353,10 +353,11 @@
353353
/* Begin XCBuildConfiguration section */
354354
13B07F941A680F5B00A75B9A /* Debug */ = {
355355
isa = XCBuildConfiguration;
356-
baseConfigurationReference = D92729E654196D4058224A10 /* Pods-example.debug.xcconfig */;
356+
baseConfigurationReference = AC77230391FFCA8A31383389 /* Pods-example.debug.xcconfig */;
357357
buildSettings = {
358358
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
359359
CODE_SIGN_ENTITLEMENTS = example/example.entitlements;
360+
CODE_SIGN_IDENTITY = "iPhone Developer: 旭东 饶 (N62595JLRL)";
360361
CODE_SIGN_STYLE = Manual;
361362
CURRENT_PROJECT_VERSION = 1;
362363
DEAD_CODE_STRIPPING = NO;
@@ -402,10 +403,11 @@
402403
};
403404
13B07F951A680F5B00A75B9A /* Release */ = {
404405
isa = XCBuildConfiguration;
405-
baseConfigurationReference = 3A20B5BF7D863E9A31C10B5A /* Pods-example.release.xcconfig */;
406+
baseConfigurationReference = 04CF78C193A0D587CF1E0CE0 /* Pods-example.release.xcconfig */;
406407
buildSettings = {
407408
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
408409
CODE_SIGN_ENTITLEMENTS = example/example.entitlements;
410+
CODE_SIGN_IDENTITY = "iPhone Developer: 旭东 饶 (N62595JLRL)";
409411
CODE_SIGN_STYLE = Manual;
410412
CURRENT_PROJECT_VERSION = 1;
411413
DEVELOPMENT_TEAM = 8X2A38Q9VD;

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"jcore-react-native": "1.6.0",
11-
"jpush-react-native": "2.7.0",
11+
"jpush-react-native": "2.7.1",
1212
"react": "16.8.6",
1313
"react-native": "0.60.5"
1414
},

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ export default class JPush {
568568
*
569569
* @param params = {"badge":int,"appBadge":int}
570570
*
571-
* badge:JPush封装badge功能,允许应用上传 badge 值至 JPush 服务器,由 JPush 后台帮助管理每个用户所对应的推送 badge 值,简化了设置推送 badge 的操作。
571+
* badge:JPush封装badge功能,允许应用上传 badge 值至 JPush 服务器,由 JPush 后台帮助管理每个用户所对应的推送 badge 值,简化了设置推送 badge 的操作。设置的值小于0,sdk时不作处理。
572572
*
573-
* appBadge:iOS 用来标记应用程序状态的一个数字,出现在程序图标右上角。
573+
* appBadge:iOS 用来标记应用程序状态的一个数字,出现在程序图标右上角。设置的值小于0,sdk时不作处理。
574574
*
575575
* */
576576
static setBadge(params) {

ios/RCTJPushModule/RCTJPushModule.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,15 @@ - (id)init
252252
{
253253
if(params[BADGE]){
254254
NSNumber *number = params[BADGE];
255+
if(number < 0) return;
255256
[JPUSHService setBadge:[number integerValue]];
256257
}
257258
if (params[APP_BADGE]) {
258259
NSNumber *number = params[APP_BADGE];
259-
[UIApplication sharedApplication].applicationIconBadgeNumber = [number integerValue];
260+
if(number < 0) return;
261+
dispatch_async(dispatch_get_main_queue(), ^{
262+
[UIApplication sharedApplication].applicationIconBadgeNumber = [number integerValue];
263+
});
260264
}
261265
}
262266

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"license": "ISC",
77
"author": "wicked.tc130",
8-
"version": "2.7.0",
8+
"version": "2.7.1",
99
"repository": {
1010
"type": "git",
1111
"url": "https://github.com/jpush/jpush-react-native"

0 commit comments

Comments
 (0)