Skip to content

Commit

Permalink
fix reference problem
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkie committed Feb 11, 2016
1 parent 1c1958a commit 8b00ed6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Example/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Example extends React.Component {
} catch (e) {
console.error(e);
}
// console.log(WeChat);
console.log(WeChat);
// console.log('getApiVersion', typeof WeChat.getApiVersion);
// console.log('getWXAppInstallUrl', typeof WeChat.getWXAppInstallUrl);
// console.log('sendRequest', typeof WeChat.sendRequest);
Expand Down
4 changes: 2 additions & 2 deletions Example/ios/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
DEAD_CODE_STRIPPING = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"$(SRCROOT)/../node_modules/react-native/React/**",
);
INFOPLIST_FILE = Example/Info.plist;
Expand All @@ -565,7 +565,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
"$(SRCROOT)/../node_modules/react-native/React/**",
);
INFOPLIST_FILE = Example/Info.plist;
Expand Down
Binary file not shown.
4 changes: 3 additions & 1 deletion ios/RCTWeChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "Base/RCTBridgeModule.h"
#import "RCTBridgeModule.h"

// define share type constants
#define RCTWXShareTypeNews @"news"
Expand All @@ -24,4 +24,6 @@

@interface RCTWeChat : NSObject <RCTBridgeModule>

@property NSString* appId;

@end
37 changes: 17 additions & 20 deletions ios/RCTWeChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// Copyright © 2015 WeFlex. All rights reserved.
//

#import "Base/RCTLog.h"
#import "RCTWeChat.h"
#import "WXApi.h"
#import "WXApiObject.h"
#import "RCTEventDispatcher.h"
#import "RCTBridge.h"
#import "Base/RCTEventDispatcher.h"
#import "Base/RCTBridge.h"
#import "Base/RCTLog.h"
#import "RCTImageLoader.h"

// Define error messages
Expand Down Expand Up @@ -55,6 +55,7 @@ - (dispatch_queue_t)methodQueue
RCT_EXPORT_METHOD(registerApp:(NSString *)appid
:(RCTResponseSenderBlock)callback)
{
self.appId = appid;
callback(@[[WXApi registerApp:appid] ? [NSNull null] : INVOKE_FAILED]);
}

Expand Down Expand Up @@ -146,7 +147,10 @@ - (dispatch_queue_t)methodQueue
[self shareToWeixinWithData:data scene:WXSceneSession callback:callback];
}

- (void)shareToWeixinWithData:(NSDictionary *)aData thumbImage:(UIImage *)aThumbImage scene:(int)aScene callBack:(RCTResponseSenderBlock)callback
- (void)shareToWeixinWithData:(NSDictionary *)aData
thumbImage:(UIImage *)aThumbImage
scene:(int)aScene
callBack:(RCTResponseSenderBlock)callback
{
SendMessageToWXReq* req = [SendMessageToWXReq new];
req.scene = aScene;
Expand All @@ -160,8 +164,7 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData thumbImage:(UIImage *)aThumb
if (text && [text isKindOfClass:[NSString class]]) {
req.text = text;
}
}
else {
} else {
req.bText = NO;

WXMediaMessage* mediaMessage = [WXMediaMessage new];
Expand All @@ -183,22 +186,19 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData thumbImage:(UIImage *)aThumb
callback(@[@"webpageUrl required"]);
return;
}
}
else if ([type isEqualToString:RCTWXShareTypeAudio]) {
} else if ([type isEqualToString:RCTWXShareTypeAudio]) {
WXMusicObject *musicObject = [WXMusicObject new];
musicObject.musicUrl = aData[@"musicUrl"];
musicObject.musicLowBandUrl = aData[@"musicLowBandUrl"];
musicObject.musicDataUrl = aData[@"musicDataUrl"];
musicObject.musicLowBandDataUrl = aData[@"musicLowBandDataUrl"];
mediaMessage.mediaObject = musicObject;
}
else if ([type isEqualToString:RCTWXShareTypeVideo]) {
} else if ([type isEqualToString:RCTWXShareTypeVideo]) {
WXVideoObject *videoObject = [WXVideoObject new];
videoObject.videoUrl = aData[@"videoUrl"];
videoObject.videoLowBandUrl = aData[@"videoLowBandUrl"];
mediaMessage.mediaObject = videoObject;
}
else if ([type isEqualToString:RCTWXShareTypeImage]) {
} else if ([type isEqualToString:RCTWXShareTypeImage]) {
WXImageObject *imageObject = [WXImageObject new];
imageObject.imageUrl = aData[RCTWXShareImageUrl];
mediaMessage.mediaObject = imageObject;
Expand All @@ -207,8 +207,7 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData thumbImage:(UIImage *)aThumb
}

BOOL success = [WXApi sendReq:req];
if (success == NO)
{
if (success == NO) {
callback(@[INVOKE_FAILED]);
}
}
Expand All @@ -221,8 +220,7 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData scene:(int)aScene callback:(
[_bridge.imageLoader loadImageWithTag:imageUrl size:CGSizeMake(100, 100) scale:1 resizeMode:UIViewContentModeScaleToFill progressBlock:nil completionBlock:^(NSError *error, UIImage *image) {
[self shareToWeixinWithData:aData thumbImage:image scene:aScene callBack:aCallBack];
}];
}
else {
} else {
[self shareToWeixinWithData:aData thumbImage:nil scene:aScene callBack:aCallBack];
}

Expand All @@ -232,7 +230,7 @@ - (void)shareToWeixinWithData:(NSDictionary *)aData scene:(int)aScene callback:(

-(void) onReq:(BaseReq*)req
{

// TODO(Yorkie)
}

-(void) onResp:(BaseResp*)resp
Expand All @@ -247,8 +245,7 @@ -(void) onResp:(BaseResp*)resp
body[@"country"] =r.country;
body[@"type"] = @"SendMessageToWX.Resp";
[self.bridge.eventDispatcher sendDeviceEventWithName:@"WeChat_Resp" body:body];
}
else if ([resp isKindOfClass:[SendAuthResp class]]) {
} else if ([resp isKindOfClass:[SendAuthResp class]]) {
SendAuthResp *r = (SendAuthResp *)resp;
NSMutableDictionary *body = @{@"errCode":@(r.errCode)}.mutableCopy;
body[@"errStr"] = r.errStr;
Expand All @@ -259,7 +256,7 @@ -(void) onResp:(BaseResp*)resp

if (resp.errCode == WXSuccess)
{
[body addEntriesFromDictionary:@{@"appid":self.appID, @"code" :r.code}];
[body addEntriesFromDictionary:@{@"appid":self.appId, @"code" :r.code}];
[self.bridge.eventDispatcher sendDeviceEventWithName:@"WeChat_Resp" body:body];
}
else {
Expand Down
14 changes: 8 additions & 6 deletions ios/RCTWeChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,10 @@
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../react-native/React",
"$(SRCROOT)/../node_modules/react-native/React",
"$(SRCROOT)/../Example/node_modules/react-native/React",
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../Example/node_modules/react-native/React/**",
"$(SRCROOT)/../Example/node_modules/react-native/Libraries/**",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -236,9 +237,10 @@
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../react-native/React",
"$(SRCROOT)/../node_modules/react-native/React",
"$(SRCROOT)/../Example/node_modules/react-native/React",
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../Example/node_modules/react-native/React/**",
"$(SRCROOT)/../Example/node_modules/react-native/Libraries/**",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
Expand Down

0 comments on commit 8b00ed6

Please sign in to comment.