{"id":20732404,"url":"https://github.com/jpush/jmessage-react-plugin","last_synced_at":"2025-04-07T06:08:11.317Z","repository":{"id":8519972,"uuid":"52926867","full_name":"jpush/jmessage-react-plugin","owner":"jpush","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-18T06:42:27.000Z","size":169156,"stargazers_count":184,"open_issues_count":43,"forks_count":45,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-30T21:09:15.785Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.jiguang.cn","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-02T02:28:20.000Z","updated_at":"2024-04-12T07:41:09.000Z","dependencies_parsed_at":"2022-09-19T21:06:39.330Z","dependency_job_id":null,"html_url":"https://github.com/jpush/jmessage-react-plugin","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjmessage-react-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjmessage-react-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjmessage-react-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpush%2Fjmessage-react-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpush","download_url":"https://codeload.github.com/jpush/jmessage-react-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T05:19:13.999Z","updated_at":"2025-04-07T06:08:11.298Z","avatar_url":"https://github.com/jpush.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jmessage-react-plugin \n\n极光官方开发的[极光 IM](https://docs.jiguang.cn/jmessage/guideline/jmessage_guide/) react-native 插件，同时支持 文字、图片、语言、文件和自定义消息。同时支持 iOS 和 Android 平台。\n\n### ChangeLog\n\n3.1.8\n\n1.需要在[AppDelegate.m](https://github.com/jpush/jmessage-react-plugin/blob/master/example/ios/JMessageDemo/AppDelegate.m) 中手动添加初始化方法，示例如下\n\n```\n#import \u003cRCTJMessageModule.h\u003e\n\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{   \n   [JMessage setupJMessage:launchOptions\n                    appKey:appKey\n                   channel:@\"\"\n          apsForProduction:isProduction\n                  category:nil\n            messageRoaming:true];\n   \n   [JMessage addDelegate:self withConversation:nil];\n}\n\n//JMessage 离线消息监听\n- (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation\n                         offlineMessages:(NSArray JMSG_GENERIC ( __kindof JMSGMessage *) *)offlineMessages {\n  [RCTJMessageEventQueue sharedInstance].offlineConversation = conversation;\n  [RCTJMessageEventQueue sharedInstance].offlineMsgArray = offlineMessages;\n}\n```\n\n2.js中初始化和监听需要在[componentDidMount()](https://github.com/jpush/jmessage-react-plugin/blob/master/example/app/routes/Launch/index.js)componentDidMount()方法内，示例如下\n\n```\ncomponentDidMount() {\n        JMessage.init({\n            appkey: appkey,\n            channel:channel\n            isOpenMessageRoaming: true,\n            isProduction: true,\n        });\n        JMessage.setDebugMode({enable: true});\n        //离线消息监听\n        JMessage.addSyncOfflineMessageListener((message) =\u003e {\n            console.log(\"| JIGUANG |===addSyncOfflineMessageListener====\" + JSON.stringify(message))\n        });\n}        \n```\n\n## 安装\n\n```\nnpm install jmessage-react-plugin --save\nnpm install jcore-react-native --save（目前 jmessage-react-plugin 2.1.1 版本需要指定安装 jcore-react-native 1.2.1 以上版本）\nreact-native link\n```\n\n##### （如果是原生应用集成 react-native）使用 CocoaPods 安装\n\n**注意： 如果已经通过 react-native link 链接了插件，则不需要执行下面的步骤。**\n\n\n在 Podfile 中添加如下代码:\n\n```\npod 'JMessageRN', :path =\u003e '../node_modules/jmessage-react-plugin'\n```\n\n终端执行如下指令:\n\n```\npod install\n```\n\n## 配置\n\n#### Android\n\n- 配置 AndroidManifest，加入 `meta-data` 部分\n```\n...\n\u003cmeta-data android:name=\"JPUSH_CHANNEL\" android:value=\"${APP_CHANNEL}\" /\u003e\n\u003cmeta-data android:name=\"JPUSH_APPKEY\" android:value=\"${JPUSH_APPKEY}\" /\u003e\n...\n```\n- 配置 build.gradle，将下列配置部分替换成自己的。\n```\ndefaultConfig {\n        applicationId \"你的 application id\"\n        minSdkVersion 16\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n        ndk {\n            abiFilters \"armeabi-v7a\", \"x86\"\n        }\n        manifestPlaceholders = [\n                JPUSH_APPKEY: \"你的 appKey\",\t//在此替换你的APPKey\n                APP_CHANNEL: \"developer-default\"\t\t//应用渠道号\n        ]\n    }\n```\n\n在 MainApplication 中加上 JMessagePackage 即可，JMessagePackage 有一个参数，设置是否弹出 toast。\n```\n// 如果设置为 true，则不弹出 toast。\nprivate boolean shutdownToast = false;\n\n@Override\nprotected List\u003cReactPackage\u003e getPackages() {\n    return Arrays.\u003cReactPackage\u003easList(\n            new MainReactPackage(),\n            new JMessageReactPackage(shutdownToast),\n    );\n}\n```\n\n#### iOS\n\n- 打开工程，进入 Build Settings -\u003e Framework search paths 添加 framework 搜索路径\n\n  ```\n  $(SRCROOT)/../node_modules/jmessage-react-plugin/ios/RCTJMessageModule\n  ```\n\n- 打开工程，进入 Build Settings -\u003e Other Link Flag 添加一行编译选项\n\n  ```\n  -framework \"JMessage\"\n  ```\n\n\n## API\n\n[API doc](./document/API.md)\n\n## 更多\n\n- QQ 群：553406342\n- [极光官网文档](http://docs.jiguang.cn/guideline/jmessage_guide/)\n- 插件问题可以直接提 [issue](https://github.com/jpush/jmessage-react-plugin/issues)\n- 有问题可访问[极光社区](http://community.jiguang.cn/)搜索和提问。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjmessage-react-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpush%2Fjmessage-react-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpush%2Fjmessage-react-plugin/lists"}