diff --git a/README.md b/README.md index fbec50e..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 @@ -76,11 +76,14 @@ public class MainApplication extends Application implements ReactApplication { #### 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" + } }