{"id":22663191,"url":"https://github.com/puti94/react-native-uni","last_synced_at":"2025-04-12T07:22:23.364Z","repository":{"id":57341115,"uuid":"271962521","full_name":"puti94/react-native-uni","owner":"puti94","description":"react-native 桥接 uni小程序sdk","archived":false,"fork":false,"pushed_at":"2020-06-17T08:08:52.000Z","size":48227,"stargazers_count":20,"open_issues_count":3,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T02:34:55.838Z","etag":null,"topics":["android","ios","react-native","rn"],"latest_commit_sha":null,"homepage":"","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/puti94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-13T07:32:51.000Z","updated_at":"2025-02-19T02:49:51.000Z","dependencies_parsed_at":"2022-09-13T00:10:37.892Z","dependency_job_id":null,"html_url":"https://github.com/puti94/react-native-uni","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puti94%2Freact-native-uni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puti94%2Freact-native-uni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puti94%2Freact-native-uni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puti94%2Freact-native-uni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puti94","download_url":"https://codeload.github.com/puti94/react-native-uni/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248531092,"owners_count":21119695,"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":["android","ios","react-native","rn"],"created_at":"2024-12-09T12:17:38.936Z","updated_at":"2025-04-12T07:22:23.333Z","avatar_url":"https://github.com/puti94.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-uni\n\nreact-native 桥接uni小程序sdk\n\n\n[uni小程序SDK](https://nativesupport.dcloud.net.cn/)\n\u003e uni-app 是一个使用 Vue.js 开发所有前端应用的框架，开发者编写一套代码，可发布到iOS、Android、H5、以及各种小程序（微信/支付宝/百度/头条/QQ/钉钉/淘宝）、快应用等多个平台。\n\n有nvue部分底层使用weex实现的，但是感觉体验还是没有rn好。rn在国内又不太接地气，没有uni各种完善的第三方框架，就可以集成uni小程序sdk，使我们的react-native应用具有跟微信小程序类似的功能。\n\n![示例](./images/example.gif)\n\n## Installation\n\n###\n\n```sh\nnpm install react-native-uni --save\n//or\nyarn add react-native-uni\n```\n\n## Usage\n\n```js\nimport * as Uni from \"react-native-uni\";\n\n// ...\nUni.initialize({...})\nUni.launch({appid: '__UNI__7586C24'})\n```\nrn \u003e= 0.60 自动链接 `cd ios \u0026\u0026 pod install`\nrn \u003c 0.60\n\n```bash\nreact-native link react-native-webview\n```\n\n安卓有些配置项请参考example项目\n\n## 注意事项\n[uni小程序官网](https://nativesupport.dcloud.net.cn/)\n此项目是在react-native中集成uni的小程序sdk，相关注意事项参考官方文档\n由于依赖weex等的相关包比较大，只是集成基础包应用都会大个20M左右。\n此桥接库只默认集成了基础包，如果提示缺少模块，只需要去官网下载sdk添加缺少的包\n\n\n## Api\n\n### initialize(params?: Config): Promise\u003cboolean\u003e\n\n```ts\ntype Config = {\n  // 胶囊按钮的标题和标识\n  items?: { title: string; key: string }[];\n  //是否显示胶囊按钮\n  capsule?: boolean;\n  //安卓独有，胶囊按钮字体大小\n  fontSize?: string;\n  //安卓独有，胶囊按钮字体颜色\n  fontColor?: string;\n  //安卓独有，胶囊按钮字体宽度\n  fontWeight?: string;\n};\n```\n初始化框架，越前面越好，只需要调用一次\n\n\n### setSplashView(component: ComponentType\u003c{ appid: string }\u003e)\n\n设置小程序开启的启动页面\n\n### launch(arg: LaunchArgs): Promise\u003cboolean\u003e\n\n```ts\ntype LaunchArgs = {\n  //uni小程序id\n  appid: string;\n  //需要传给小程序的参数\n  params?: Object;\n  //打开小程序的路径\n  path?: string;\n};\n```\n\n打开小程序。\n\n### isExistsApp(appid: string): Promise\u003cboolean\u003e\n\n根据小程序id判断是否存在小程序\n\n### getRuningAppid(): Promise\u003cstring | null\u003e\n\n获取真正运行的小程序id\n\n### getAppVersionInfo(appid: string): Promise\u003c{ name: string; code: number } | null\u003e\n\n获取小程序版本信息\n\n### getAppBasePath(appid: string): Promise\u003cstring\u003e\n\n获取小程序运行路径\n\n### getCurrentPageUrl(): Promise\u003cstring\u003e\n\n获取当前小程序的直连url\n\n### closeCurrentApp(): Promise\u003cboolean\u003e\n\n关闭当前小程序\n\n### releaseWgtToRunPathFromPath(path: string): Promise\u003cboolean\u003e\n\n释放wgt文件\n\n### onMenuClick(cb: (key: any) =\u003e void)\n\n监听胶囊自定义按键启动\n\n### onEventReceive(cb: (data: any) =\u003e void)\n\n监听小程序向app发送的消息\n\n### onAppClose(cb: () =\u003e void)\n\n监听小程序关闭\n\n## QA\n\n#### 打release包出现以下错误\n\u003e  A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade\n   More than one file was found with OS independent path 'AndroidManifest.xml'\n\n `android/build.gradle` 修改gradle版本 `classpath(\"com.android.tools.build:gradle:3.4.0\")`\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputi94%2Freact-native-uni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fputi94%2Freact-native-uni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputi94%2Freact-native-uni/lists"}