{"id":27938821,"url":"https://github.com/osdio/react-native-wechat-api","last_synced_at":"2025-05-07T08:57:59.415Z","repository":{"id":84847900,"uuid":"44902793","full_name":"osdio/react-native-wechat-api","owner":"osdio","description":"A react-native wrapper for wechat API","archived":false,"fork":false,"pushed_at":"2015-10-30T16:29:02.000Z","size":4379,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T08:57:51.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/osdio.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":"2015-10-25T08:54:24.000Z","updated_at":"2016-01-04T23:25:14.000Z","dependencies_parsed_at":"2023-03-03T03:30:42.180Z","dependency_job_id":null,"html_url":"https://github.com/osdio/react-native-wechat-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdio%2Freact-native-wechat-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdio%2Freact-native-wechat-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdio%2Freact-native-wechat-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osdio%2Freact-native-wechat-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osdio","download_url":"https://codeload.github.com/osdio/react-native-wechat-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847507,"owners_count":21813450,"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":"2025-05-07T08:57:58.912Z","updated_at":"2025-05-07T08:57:59.402Z","avatar_url":"https://github.com/osdio.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-wechat-api\n\n\u003e A react-native wrapper for wechat API\n\n\n# install\n\n```\nnpm i react-native-wechat-api --save\n```\n\n将`ios/RNWechatAPI.xcodeproj`添加到项目中, link如下库:\n\n ![D90D3626-3385-45E9-AAB7-ADF43257EE4B.png](http://dn-cnode.qbox.me/FsRG0pqZ_6h5b_QVx8EZ3ToEf6jv)\n \n\n# 项目引用\n\n### 引用需要的文件头\n\n在AppDelegate中加入以下代码:\n\n```\n\n#import \"WXApi.h\"\n#import \"WXApiManager.h\"\n\n```\n\n\n### 要使你的程序启动后微信终端能响应你的程序，必须在代码中向微信终端注册你的id。\n\n在AppDelegate 的 didFinishLaunchingWithOptions 函数中向微信注册id:\n\n```\n\n[WXApi registerApp:@\"your id\" withDescription:@\"demo 2.0\"];\n\n```\n\n### 重写AppDelegate的handleOpenURL和openURL方法：\n\n```\n\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {\n  return  [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];\n}\n\n- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {\n  return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];\n}\n\n```\n\n\n\n\n# API\n\n### sendAuthReq(scope,state,openID)\n\n此方法用于微信登陆认证, 相对应有个回调事件:\n\n```\n\n constructor(props) {\n        super(props);\n        this.eventEmitter = NativeAppEventEmitter.addListener('didRecvAuthResponse', this._onAuthRes.bind(this));\n    }\n\n\n    componentWillUnmount() {\n        this.eventEmitter.remove();\n    }\n\n\n    _onAuthRes(e) {\n        console.log(e);\n    }\n    \n```\n\n# FAQ\n\n* 目前只实现了登陆认证API, 其实其他API实现其实也很简单, 稍微改动一下代码就行, 但是目前感觉略坑的是, 分享API每次得需要一个image, 而js\n调用oc目前我还没有找到一个好的模式去用这个分享API, 难道每次传一个url path? 当然如果你有更好的想法, 欢迎提交PR.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosdio%2Freact-native-wechat-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosdio%2Freact-native-wechat-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosdio%2Freact-native-wechat-api/lists"}