From 6082db645b1e421b572e796644aad070c9faa9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=8D=9A?= Date: Fri, 16 Jun 2017 09:52:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=89=E5=8D=93promisify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ index.js | 9 ++++++++- package.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fbec50e..9250057 100644 --- a/README.md +++ b/README.md @@ -75,12 +75,14 @@ public class MainApplication extends Application implements ReactApplication { ### 3.工程配置 #### ios配置 将`node_modules/react-native-weibo/ios/libWeiboSDK/WeiboSDK.bundle`加入到工程中(必须,很重要,不然登录的时候会crash) +在Build Phases ➜ Copy Bundle Resources ➜ Add Other... libWeiboSDK/WeiboSDK.bundle 在工程target的`Build Phases->Link Binary with Libraries`中加入`libRCTWeiboAPI.a、libsqlite3.tbd、libz.tbd、ImageIO.framework、SystemConfiguration.framework、Security.framework、CoreTelephony.framework、CoreText.framework` 在`Info->URL Types` 中增加QQ的scheme: `Identifier` 设置为`sina`, `URL Schemes` 设置为你注册的微博开发者账号中的APPID,需要加前缀`wb`,例如`wb1915346979` + 在你工程的`AppDelegate.m`文件中添加如下代码: ``` diff --git a/index.js b/index.js index 5d1ca37..527a63b 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,6 @@ */ import {NativeModules, NativeAppEventEmitter} from 'react-native'; -import promisify from 'es6-promisify'; const {WeiboAPI} = NativeModules; @@ -33,6 +32,14 @@ function wrapApi(nativeFunc) { }; } +function promisify(fn, handler) { + return function (...args) { + return new Promise(function (resolve, reject) { + fn(...args, handler.bind({ resolve, reject })) + }) + } +} + // Save callback and wait for future event. let savedCallback = undefined; function waitForResponse(type) { diff --git a/package.json b/package.json index 5bc592b..bde9933 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ }, "homepage": "https://github.com/reactnativecn/react-native-weibo#readme", "dependencies": { - "es6-promisify": "^3.0.0" + } } From bab79e7e969d2aaf84a8eae545516066b8ba32a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=91=E8=A8=80?= <303152878@qq.com> Date: Fri, 16 Jun 2017 09:55:28 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9250057..afdf542 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ react-native link ``` #### 手动link~(如果不能够自动link) -#####ios +####ios a.打开XCode's工程中, 右键点击Libraries文件夹 ➜ Add Files to <...> b.去node_modules ➜ react-native-weibo ➜ ios ➜ 选择 RCTWeiboAPI.xcodeproj c.在工程Build Phases ➜ Link Binary With Libraries中添加libRCTWeiboAPI.a -#####Android +####Android ``` // file: android/settings.gradle @@ -75,6 +75,7 @@ public class MainApplication extends Application implements ReactApplication { ### 3.工程配置 #### ios配置 将`node_modules/react-native-weibo/ios/libWeiboSDK/WeiboSDK.bundle`加入到工程中(必须,很重要,不然登录的时候会crash) + 在Build Phases ➜ Copy Bundle Resources ➜ Add Other... libWeiboSDK/WeiboSDK.bundle 在工程target的`Build Phases->Link Binary with Libraries`中加入`libRCTWeiboAPI.a、libsqlite3.tbd、libz.tbd、ImageIO.framework、SystemConfiguration.framework、Security.framework、CoreTelephony.framework、CoreText.framework` From 499165a849ba39b24356e75f2d2d42df3fe923bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=91=E8=A8=80?= <303152878@qq.com> Date: Fri, 16 Jun 2017 09:56:21 +0800 Subject: [PATCH 3/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index afdf542..d07c4d7 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ react-native link ``` #### 手动link~(如果不能够自动link) -####ios +##### ios a.打开XCode's工程中, 右键点击Libraries文件夹 ➜ Add Files to <...> b.去node_modules ➜ react-native-weibo ➜ ios ➜ 选择 RCTWeiboAPI.xcodeproj c.在工程Build Phases ➜ Link Binary With Libraries中添加libRCTWeiboAPI.a -####Android +##### Android ``` // file: android/settings.gradle