JPush's officially supported React Native plugin (Android & iOS). 极光推送官方支持的 React Native 插件(Android & iOS)。
MIT License
Bot releases are hidden (Show)
Published by KenChoi1992 about 7 years ago
jpush-react-native 插件工程 移除 -ljcore-ios 编译选项,jcore 依赖改为 link jcore 工程的形式,如果提示 jcore 类库没有找到,需要更新到 jcore 1.1.8 以上版本。
npm install [email protected]
react-native link
Published by KenChoi1992 about 7 years ago
Published by KenChoi1992 about 7 years ago
升级此版本会导致和 RN 0.47 以下版本不兼容。原因在于 RN 0.47 版本去掉了 ReactPackage 中的 createJSModules 接口方法,而不是标注过期。兼容 RN 0.47 以下解决方案:在 JPushPackage 中加入 createJSModules 的实现:
@Override
public List<ViewManager> createJSModules(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
Published by huangminlinux about 7 years ago
npm install [email protected] --save
RCTJPushModule
这个子工程react-native unlink jpush-react-native
react-native link jpush-react-native
$(SRCROOT)/../node_modules/jpush-react-native/ios/RCTJPushModule
所有 iOS 的事件的监听方式统一改成和 Android 一样的接口调用形式,变动如下(下面接口如没有特别说明,iOS 、Android 通用)
改动前的事件 | 改动后,通过调用接口的方式来监听该事件 |
---|---|
ReceiveNotification | JPushModule.addReceiveNotificationListener |
networkDidReceiveMessage | JPushModule.addReceiveCustomMsgListener |
OpenNotification | JPushModule.addReceiveOpenNotificationListener |
OpenNotificationToLaunchApp(iOS Only) | JPushModule.openNotificationLaunchAppEvent (iOS Only) |
networkDidSetup、 networkDidClose | JPushModule.addConnectionChangeListener |
networkDidLogin | JPushModule.addnetworkDidLoginListener |
Published by KenChoi1992 over 7 years ago
Published by huangminlinux over 7 years ago
OpenNotification
event Separated into OpenNotificationToLaunchApp
and OpenNotification
OpenNotificationToLaunchApp
event,fire when open notification and launch app。
OpenNotification
event,fire when user click notification (available in iOS 10)。
var subscription = NativeAppEventEmitter.addListener(
'OpenNotificationToLaunchApp',
(notification) => console.log(notification)
);
Published by KenChoi1992 over 7 years ago
clearNotificationById
,参数由 string 改为 numbernotifyJSDidLoad
为异步接口jumpToPushActivity
,在收到通知后,点击跳转到指定界面。详情请参考 demo 的使用。Published by KenChoi1992 over 7 years ago
componentDidMount() {
JPushModule.notifyJSDidLoad();
JPushModule.addReceiveCustomMsgListener((map) => {
this.setState({
pushMsg: map.message
});
console.log("extras: " + map.extras);
});
JPushModule.addReceiveNotificationListener((map) => {
console.log("alertContent: " + map.alertContent);
console.log("extras: " + map.extras);
// var extra = JSON.parse(map.extras);
// console.log(extra.key + ": " + extra.value);
});
JPushModule.addReceiveOpenNotificationListener((map) => {
console.log("Opening notification!");
console.log("map.extra: " + map.key);
});
JPushModule.addGetRegistrationIdListener((registrationId) => {
console.log("Device register succeed, registrationId " + registrationId);
});
}
componentDidMount() {
JPushModule.notifyJSDidLoad();
JPushModule.addReceiveCustomMsgListener((map) => {
this.setState({
pushMsg: map.message
});
console.log("extras: " + map.extras);
});
JPushModule.addReceiveNotificationListener((map) => {
console.log("alertContent: " + map.alertContent);
console.log("extras: " + map.extras);
// var extra = JSON.parse(map.extras);
// console.log(extra.key + ": " + extra.value);
});
JPushModule.addReceiveOpenNotificationListener((map) => {
console.log("Opening notification!");
console.log("map.extra: " + map.key);
});
JPushModule.addGetRegistrationIdListener((registrationId) => {
console.log("Device register succeed, registrationId " + registrationId);
});
}
Published by KenChoi1992 over 7 years ago
Published by KenChoi1992 over 7 years ago
用法:
JPushModule.setAliasAndTags(alias, [], () => {
console.log("Set alias and tags succeed");
}, () => {
console.log("Set alias and tags failed");
})
usage:
JPushModule.setAliasAndTags(alias, [], () => {
console.log("Set alias and tags succeed");
}, () => {
console.log("Set alias and tags failed");
})
Published by KenChoi1992 over 7 years ago
Published by KenChoi1992 over 7 years ago
更新 README。
Updated README.
Published by KenChoi1992 over 7 years ago
Published by KenChoi1992 over 7 years ago
Published by huangminlinux over 7 years ago
change log:
fix ios isJPushDidLogin status error bug
更新改动:
修复热更新 isJPushDidLogin 状态错误问题
Published by KenChoi1992 over 7 years ago
Published by KenChoi1992 over 7 years ago
Receive notifications while app is not running(background or foreground), will save as local notifications.
Published by KenChoi1992 over 7 years ago
Add try-catch to receiver when receiving ACTION_REGISTRATION_ID , avoid crash while ReactContext is null.
Published by huangminlinux over 7 years ago
change log:
added rnpm sharedLibraries in package.json.
After 1.5.0 version, do not have to add sharedLibraries manually
change log:
在 package.json 添加 rnpm sharedLibraries 工程中的必要库,1.5.0 版本之后不需要手动添加这些库了
Published by huangminlinux over 7 years ago
fix bug:
fix hot reload Duplicate subscription notification bug.
修复bug:
修复热更新重复订阅的bug。