mirror of
https://github.com/zhigang1992/react-native-wechat-1.git
synced 2026-01-12 09:24:20 +08:00
init
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pbxproj -text
|
||||
46
.gitignore
vendored
Normal file
46
.gitignore
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
# OSX
|
||||
#
|
||||
.DS_Store
|
||||
|
||||
# node.js
|
||||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
project.xcworkspace
|
||||
|
||||
|
||||
# Android/IntelliJ
|
||||
#
|
||||
build/
|
||||
.idea
|
||||
.gradle
|
||||
local.properties
|
||||
*.iml
|
||||
|
||||
# BUCK
|
||||
buck-out/
|
||||
\.buckd/
|
||||
*.keystore
|
||||
|
||||
53
README.md
Normal file
53
README.md
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
# react-native-wechat
|
||||
|
||||
## Getting started
|
||||
|
||||
`$ npm install react-native-wechat --save`
|
||||
|
||||
### Mostly automatic installation
|
||||
|
||||
`$ react-native link react-native-wechat`
|
||||
|
||||
### Manual installation
|
||||
|
||||
|
||||
#### iOS
|
||||
|
||||
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
||||
2. Go to `node_modules` ➜ `react-native-wechat` and add `RNWechat.xcodeproj`
|
||||
3. In XCode, in the project navigator, select your project. Add `libRNWechat.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
||||
4. Run your project (`Cmd+R`)<
|
||||
|
||||
#### Android
|
||||
|
||||
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
||||
- Add `import com.reactlibrary.RNWechatPackage;` to the imports at the top of the file
|
||||
- Add `new RNWechatPackage()` to the list returned by the `getPackages()` method
|
||||
2. Append the following lines to `android/settings.gradle`:
|
||||
```
|
||||
include ':react-native-wechat'
|
||||
project(':react-native-wechat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wechat/android')
|
||||
```
|
||||
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
||||
```
|
||||
compile project(':react-native-wechat')
|
||||
```
|
||||
|
||||
#### Windows
|
||||
[Read it! :D](https://github.com/ReactWindows/react-native)
|
||||
|
||||
1. In Visual Studio add the `RNWechat.sln` in `node_modules/react-native-wechat/windows/RNWechat.sln` folder to their solution, reference from their app.
|
||||
2. Open up your `MainPage.cs` app
|
||||
- Add `using Wechat.RNWechat;` to the usings at the top of the file
|
||||
- Add `new RNWechatPackage()` to the `List<IReactPackage>` returned by the `Packages` method
|
||||
|
||||
|
||||
## Usage
|
||||
```javascript
|
||||
import RNWechat from 'react-native-wechat';
|
||||
|
||||
// TODO: What to do with the module?
|
||||
RNWechat;
|
||||
```
|
||||
|
||||
36
android/build.gradle
Normal file
36
android/build.gradle
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.3.1'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.facebook.react:react-native:+'
|
||||
compile 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
|
||||
}
|
||||
3
android/proguard-rules.pro
vendored
Normal file
3
android/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
-keep class com.tencent.mm.opensdk.** { *; }
|
||||
-keep class com.tencent.wxop.** { *; }
|
||||
-keep class com.tencent.mm.sdk.** { *; }
|
||||
5
android/src/main/AndroidManifest.xml
Normal file
5
android/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.ytanglib.wechat">
|
||||
|
||||
</manifest>
|
||||
203
android/src/main/java/com/ytanglib/wechat/RNWechatModule.java
Normal file
203
android/src/main/java/com/ytanglib/wechat/RNWechatModule.java
Normal file
@@ -0,0 +1,203 @@
|
||||
package com.ytanglib.wechat;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
|
||||
|
||||
public class RNWechatModule extends ReactContextBaseJavaModule {
|
||||
private static ReactApplicationContext mReactContext;
|
||||
private static final String Tag = "RNWechat";
|
||||
private static final String RNWechatEventName = "RNWechatEvent";
|
||||
private static IWXAPI api;
|
||||
private boolean isWXApiRegisteSuccess = false;
|
||||
|
||||
public RNWechatModule(ReactApplicationContext reactContext, String appId) {
|
||||
super(reactContext);
|
||||
mReactContext = reactContext;
|
||||
|
||||
if (!appId.isEmpty()) {
|
||||
api = WXAPIFactory.createWXAPI(reactContext, appId, true);
|
||||
isWXApiRegisteSuccess = api.registerApp(appId);
|
||||
if (isWXApiRegisteSuccess) {
|
||||
Log.i(Tag, "WXApi register success. appId: " + appId);
|
||||
} else {
|
||||
Log.i(Tag, "WXApi register failed. appId: " + appId);
|
||||
}
|
||||
|
||||
} else {
|
||||
Log.i(Tag, "There is no appId for WXApi.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RNWechat";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void isWXApiRegisteSuccess(Promise promise) {
|
||||
promise.resolve(getOperateResult(isWXApiRegisteSuccess));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void isWXAppInstalled(Promise promise) {
|
||||
promise.resolve(getOperateResult(api.isWXAppInstalled()));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendAuthRequestScope(
|
||||
String scope,
|
||||
String state,
|
||||
String openId,
|
||||
Promise promise)
|
||||
{
|
||||
final SendAuth.Req req = new SendAuth.Req();
|
||||
req.scope = scope;
|
||||
req.state = state;
|
||||
req.openId = openId;
|
||||
boolean res = api.sendReq(req);
|
||||
promise.resolve(getOperateResult(res));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendText(
|
||||
String text,
|
||||
Integer sceneType,
|
||||
Promise promise)
|
||||
{
|
||||
WXTextObject textObject = new WXTextObject();
|
||||
textObject.text = text;
|
||||
|
||||
WXMediaMessage mediaMessage = getMediaMessageWithData(null,null,null, textObject);
|
||||
promise.resolve(getOperateResult(sendMessageRequest(mediaMessage, sceneType)));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendLinkURL(
|
||||
String urlString,
|
||||
String title,
|
||||
String description,
|
||||
String thumbUrlString,
|
||||
Integer sceneType,
|
||||
Promise promise)
|
||||
{
|
||||
WXWebpageObject webObj = new WXWebpageObject();
|
||||
webObj.webpageUrl = urlString;
|
||||
|
||||
byte[] thumbByteArray = Utils.getByteArrayFromUrlStringWithScale(thumbUrlString, 100, 100);
|
||||
|
||||
WXMediaMessage mediaMessage = getMediaMessageWithData(title, description, thumbByteArray, webObj);
|
||||
promise.resolve(getOperateResult(sendMessageRequest(mediaMessage, sceneType)));
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendMiniProgramWebpageUrl(
|
||||
String webpageUrl,
|
||||
String userName,
|
||||
String path,
|
||||
String title,
|
||||
String description,
|
||||
String thumbUrlString,
|
||||
String hdImageUrlString,
|
||||
Integer programType,
|
||||
Promise promise)
|
||||
{
|
||||
WXMiniProgramObject miniObj = new WXMiniProgramObject();
|
||||
miniObj.webpageUrl = webpageUrl;
|
||||
miniObj.userName = userName;
|
||||
miniObj.path = path;
|
||||
miniObj.miniprogramType = programType;
|
||||
miniObj.withShareTicket = true;
|
||||
|
||||
String imageUrlString = hdImageUrlString.isEmpty() ? thumbUrlString : hdImageUrlString;
|
||||
byte[] thumbByteArray = Utils.getByteArrayFromUrlStringWithScale(imageUrlString, 500, 400);
|
||||
|
||||
WXMediaMessage mediaMessage = getMediaMessageWithData(title, description, thumbByteArray, miniObj);
|
||||
promise.resolve(getOperateResult(sendMessageRequest(mediaMessage, SendMessageToWX.Req.WXSceneSession)));
|
||||
}
|
||||
|
||||
private String getOperateResult(boolean isOperateSucc) {
|
||||
return isOperateSucc ? "true" : "false";
|
||||
}
|
||||
|
||||
private WXMediaMessage getMediaMessageWithData(
|
||||
String title,
|
||||
String description,
|
||||
byte[] thumbData,
|
||||
WXMediaMessage.IMediaObject mediaObject)
|
||||
{
|
||||
WXMediaMessage mediaMessage = new WXMediaMessage();
|
||||
mediaMessage.title = title;
|
||||
mediaMessage.description = description;
|
||||
mediaMessage.thumbData = thumbData;
|
||||
mediaMessage.mediaObject = mediaObject;
|
||||
return mediaMessage;
|
||||
}
|
||||
|
||||
private boolean sendMessageRequest(WXMediaMessage mediaMessage, Integer scene) {
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.message = mediaMessage;
|
||||
req.scene = scene;
|
||||
return api.sendReq(req);
|
||||
}
|
||||
|
||||
public static void handleIntent(Intent intent) {
|
||||
api.handleIntent(intent, new IWXAPIEventHandler() {
|
||||
@Override
|
||||
public void onReq(BaseReq baseReq) {
|
||||
// wechat send request to app
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResp(BaseResp baseResp) {
|
||||
WritableMap body = Arguments.createMap();
|
||||
body.putInt("errCode", baseResp.errCode);
|
||||
body.putString("errStr", Utils.checkNullableString(baseResp.errStr));
|
||||
// body.putString("transaction", Utils.checkNullableString(baseResp.transaction));
|
||||
// body.putString("openId", Utils.checkNullableString(baseResp.openId));
|
||||
|
||||
if (baseResp instanceof SendMessageToWX.Resp) {
|
||||
SendMessageToWX.Resp resp = (SendMessageToWX.Resp) baseResp;
|
||||
body.putString("eventType", "SendMessageToWXResp");
|
||||
|
||||
} else if (baseResp instanceof SendAuth.Resp) {
|
||||
SendAuth.Resp resp = (SendAuth.Resp) baseResp;
|
||||
body.putString("eventType", "SendAuthResp");
|
||||
body.putString("code", Utils.checkNullableString(resp.code));
|
||||
body.putString("state", Utils.checkNullableString(resp.state));
|
||||
body.putString("url", Utils.checkNullableString(resp.url));
|
||||
body.putString("lang", Utils.checkNullableString(resp.lang));
|
||||
body.putString("country", Utils.checkNullableString(resp.country));
|
||||
}
|
||||
|
||||
RNWechatModule.sendEvent(body);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void sendEvent(WritableMap mBody) {
|
||||
mReactContext
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit(RNWechatEventName, mBody);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
package com.ytanglib.wechat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.ytanglib.wechat.RNWechatModule;
|
||||
|
||||
public class RNWechatPackage implements ReactPackage {
|
||||
private String appId;
|
||||
|
||||
public RNWechatPackage(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Arrays.<NativeModule>asList(new RNWechatModule(reactContext, this.appId));
|
||||
}
|
||||
|
||||
// Deprecated from RN 0.47
|
||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
66
android/src/main/java/com/ytanglib/wechat/Utils.java
Normal file
66
android/src/main/java/com/ytanglib/wechat/Utils.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.ytanglib.wechat;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
|
||||
/**
|
||||
* Created by dayudong on 08/03/2018.
|
||||
*/
|
||||
|
||||
public class Utils {
|
||||
public static String checkNullableString(String str) {
|
||||
return str != null ? str : "";
|
||||
}
|
||||
|
||||
public static byte[] getByteArrayFromUrlStringWithScale(String urlString, int width, int height) {
|
||||
Bitmap bitmap = getBitmapFromUrlString(urlString);
|
||||
Bitmap resizeBitmap = getResizeBitmapFromBitmap(bitmap, width, height);
|
||||
return transformBitmapToByteArray(resizeBitmap);
|
||||
}
|
||||
|
||||
private static Bitmap getBitmapFromUrlString(String urlString) {
|
||||
if (urlString.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Bitmap imageBitmap = null;
|
||||
try {
|
||||
URL imageUrl = new URL(urlString);
|
||||
HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
|
||||
conn.setDoInput(true);
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.connect();
|
||||
InputStream imageStream = conn.getInputStream();
|
||||
imageBitmap = BitmapFactory.decodeStream(imageStream);
|
||||
} catch (Exception ignored) {}
|
||||
return imageBitmap;
|
||||
}
|
||||
|
||||
private static Bitmap getResizeBitmapFromBitmap(Bitmap bitmap, int newWidth, int newHeight) {
|
||||
if (bitmap == null) {
|
||||
return null;
|
||||
}
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
float scaleWidth = ((float) newWidth) / width;
|
||||
float scaleHeight = ((float) newHeight) / height;
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
|
||||
}
|
||||
|
||||
private static byte[] transformBitmapToByteArray(Bitmap bitmap) {
|
||||
if (bitmap == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
4
index.js
Normal file
4
index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import WXApi from './src/index'
|
||||
|
||||
export { WXErrCode } from './src/const'
|
||||
export default WXApi
|
||||
110
ios/Handler/WXApiRequestHandler.h
Normal file
110
ios/Handler/WXApiRequestHandler.h
Normal file
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// WXApiManager.h
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "WXApiObject.h"
|
||||
|
||||
@interface WXApiRequestHandler : NSObject
|
||||
|
||||
+ (BOOL)sendText:(NSString *)text
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendImageData:(NSData *)imageData
|
||||
TagName:(NSString *)tagName
|
||||
MessageExt:(NSString *)messageExt
|
||||
Action:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendLinkURL:(NSString *)urlString
|
||||
TagName:(NSString *)tagName
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendMusicURL:(NSString *)musicURL
|
||||
dataURL:(NSString *)dataURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendVideoURL:(NSString *)videoURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendEmotionData:(NSData *)emotionData
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendFileData:(NSData *)fileData
|
||||
fileExtension:(NSString *)extension
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)sendMiniProgramWebpageUrl:(NSString *)webpageUrl
|
||||
userName:(NSString *)userName
|
||||
path:(NSString *)path
|
||||
title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
hdImageData:(NSData *)hdImageData
|
||||
withShareTicket:(BOOL)withShareTicket
|
||||
miniProgramType:(WXMiniProgramType)programType
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)launchMiniProgramWithUserName:(NSString *)userName
|
||||
path:(NSString *)path
|
||||
type:(WXMiniProgramType)miniProgramType;
|
||||
|
||||
+ (BOOL)sendAppContentData:(NSData *)data
|
||||
ExtInfo:(NSString *)info
|
||||
ExtURL:(NSString *)url
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene;
|
||||
|
||||
+ (BOOL)addCardsToCardPackage:(NSArray *)cardIds cardExts:(NSArray *)cardExts;
|
||||
|
||||
+ (BOOL)sendAuthRequestScope:(NSString *)scope
|
||||
State:(NSString *)state
|
||||
OpenID:(NSString *)openID;
|
||||
|
||||
+ (BOOL)openProfileWithAppID:(NSString *)appID
|
||||
Description:(NSString *)description
|
||||
UserName:(NSString *)userName
|
||||
ExtMsg:(NSString *)extMessage;
|
||||
|
||||
+ (BOOL)jumpToBizWebviewWithAppID:(NSString *)appID
|
||||
Description:(NSString *)description
|
||||
tousrname:(NSString *)tousrname
|
||||
ExtMsg:(NSString *)extMsg;
|
||||
|
||||
+ (BOOL)chooseCard:(NSString *)appid
|
||||
cardSign:(NSString *)cardSign
|
||||
nonceStr:(NSString *)nonceStr
|
||||
signType:(NSString *)signType
|
||||
timestamp:(UInt32)timestamp;
|
||||
|
||||
+ (BOOL)openUrl:(NSString *)url;
|
||||
|
||||
+ (BOOL)chooseInvoice:(NSString *)appid
|
||||
cardSign:(NSString *)cardSign
|
||||
nonceStr:(NSString *)nonceStr
|
||||
signType:(NSString *)signType
|
||||
timestamp:(UInt32)timestamp;
|
||||
|
||||
@end
|
||||
339
ios/Handler/WXApiRequestHandler.m
Normal file
339
ios/Handler/WXApiRequestHandler.m
Normal file
@@ -0,0 +1,339 @@
|
||||
//
|
||||
// WXApiManager.m
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXApi.h"
|
||||
#import "WXApiRequestHandler.h"
|
||||
#import "SendMessageToWXReq+requestWithTextOrMediaMessage.h"
|
||||
#import "WXMediaMessage+messageConstruct.h"
|
||||
|
||||
@implementation WXApiRequestHandler
|
||||
|
||||
#pragma mark - Public Methods
|
||||
+ (BOOL)sendText:(NSString *)text
|
||||
InScene:(enum WXScene)scene {
|
||||
SendMessageToWXReq *req = [SendMessageToWXReq requestWithText:text
|
||||
OrMediaMessage:nil
|
||||
bText:YES
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendImageData:(NSData *)imageData
|
||||
TagName:(NSString *)tagName
|
||||
MessageExt:(NSString *)messageExt
|
||||
Action:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXImageObject *ext = [WXImageObject object];
|
||||
ext.imageData = imageData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:nil
|
||||
Description:nil
|
||||
Object:ext
|
||||
MessageExt:messageExt
|
||||
MessageAction:action
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:tagName];
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendLinkURL:(NSString *)urlString
|
||||
TagName:(NSString *)tagName
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXWebpageObject *ext = [WXWebpageObject object];
|
||||
ext.webpageUrl = urlString;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:tagName];
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendMusicURL:(NSString *)musicURL
|
||||
dataURL:(NSString *)dataURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXMusicObject *ext = [WXMusicObject object];
|
||||
ext.musicUrl = musicURL;
|
||||
ext.musicDataUrl = dataURL;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendVideoURL:(NSString *)videoURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
message.title = title;
|
||||
message.description = description;
|
||||
[message setThumbImage:thumbImage];
|
||||
|
||||
WXVideoObject *ext = [WXVideoObject object];
|
||||
ext.videoUrl = videoURL;
|
||||
|
||||
message.mediaObject = ext;
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendEmotionData:(NSData *)emotionData
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
[message setThumbImage:thumbImage];
|
||||
|
||||
WXEmoticonObject *ext = [WXEmoticonObject object];
|
||||
ext.emoticonData = emotionData;
|
||||
|
||||
message.mediaObject = ext;
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendFileData:(NSData *)fileData
|
||||
fileExtension:(NSString *)extension
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
message.title = title;
|
||||
message.description = description;
|
||||
[message setThumbImage:thumbImage];
|
||||
|
||||
WXFileObject *ext = [WXFileObject object];
|
||||
ext.fileExtension = @"pdf";
|
||||
ext.fileData = fileData;
|
||||
|
||||
message.mediaObject = ext;
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)sendMiniProgramWebpageUrl:(NSString *)webpageUrl
|
||||
userName:(NSString *)userName
|
||||
path:(NSString *)path
|
||||
title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
hdImageData:(NSData *)hdImageData
|
||||
withShareTicket:(BOOL)withShareTicket
|
||||
miniProgramType:(WXMiniProgramType)programType
|
||||
InScene:(enum WXScene)scene
|
||||
{
|
||||
WXMiniProgramObject *ext = [WXMiniProgramObject object];
|
||||
ext.webpageUrl = webpageUrl;
|
||||
ext.userName = userName;
|
||||
ext.path = path;
|
||||
ext.hdImageData = hdImageData;
|
||||
ext.withShareTicket = withShareTicket;
|
||||
ext.miniProgramType = programType;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)launchMiniProgramWithUserName:(NSString *)userName
|
||||
path:(NSString *)path
|
||||
type:(WXMiniProgramType)miniProgramType
|
||||
{
|
||||
WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
|
||||
launchMiniProgramReq.userName = userName;
|
||||
launchMiniProgramReq.path = path;
|
||||
launchMiniProgramReq.miniProgramType = miniProgramType;
|
||||
|
||||
return [WXApi sendReq:launchMiniProgramReq];
|
||||
}
|
||||
|
||||
|
||||
|
||||
+ (BOOL)sendAppContentData:(NSData *)data
|
||||
ExtInfo:(NSString *)info
|
||||
ExtURL:(NSString *)url
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
InScene:(enum WXScene)scene {
|
||||
WXAppExtendObject *ext = [WXAppExtendObject object];
|
||||
ext.extInfo = info;
|
||||
ext.url = url;
|
||||
ext.fileData = data;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:messageExt
|
||||
MessageAction:action
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
SendMessageToWXReq* req = [SendMessageToWXReq requestWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO
|
||||
InScene:scene];
|
||||
return [WXApi sendReq:req];
|
||||
|
||||
}
|
||||
|
||||
+ (BOOL)addCardsToCardPackage:(NSArray *)cardIds cardExts:(NSArray *)cardExts{
|
||||
NSMutableArray *cardItems = [NSMutableArray array];
|
||||
for (NSString *cardId in cardIds) {
|
||||
WXCardItem *item = [[WXCardItem alloc] init];
|
||||
item.cardId = cardId;
|
||||
item.appID = @"wxf8b4f85f3a794e77";
|
||||
[cardItems addObject:item];
|
||||
}
|
||||
|
||||
for (NSInteger index = 0; index < cardItems.count; index++) {
|
||||
WXCardItem *item = cardItems[index];
|
||||
NSString *ext = cardExts[index];
|
||||
item.extMsg = ext;
|
||||
}
|
||||
|
||||
AddCardToWXCardPackageReq *req = [[AddCardToWXCardPackageReq alloc] init];
|
||||
req.cardAry = cardItems;
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)chooseCard:(NSString *)appid
|
||||
cardSign:(NSString *)cardSign
|
||||
nonceStr:(NSString *)nonceStr
|
||||
signType:(NSString *)signType
|
||||
timestamp:(UInt32)timestamp
|
||||
{
|
||||
WXChooseCardReq *chooseCardReq = [[WXChooseCardReq alloc] init];
|
||||
chooseCardReq.appID = appid;
|
||||
chooseCardReq.cardSign = cardSign;
|
||||
chooseCardReq.nonceStr = nonceStr;
|
||||
chooseCardReq.signType = signType;
|
||||
chooseCardReq.timeStamp = timestamp;
|
||||
return [WXApi sendReq:chooseCardReq];
|
||||
|
||||
}
|
||||
|
||||
+ (BOOL)sendAuthRequestScope:(NSString *)scope
|
||||
State:(NSString *)state
|
||||
OpenID:(NSString *)openID {
|
||||
SendAuthReq* req = [[SendAuthReq alloc] init];
|
||||
req.scope = scope; // @"post_timeline,sns"
|
||||
req.state = state;
|
||||
req.openID = openID;
|
||||
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)openProfileWithAppID:(NSString *)appID
|
||||
Description:(NSString *)description
|
||||
UserName:(NSString *)userName
|
||||
ExtMsg:(NSString *)extMessage {
|
||||
[WXApi registerApp:appID];
|
||||
JumpToBizProfileReq *req = [[JumpToBizProfileReq alloc]init];
|
||||
req.profileType = WXBizProfileType_Device;
|
||||
req.username = userName;
|
||||
req.extMsg = extMessage;
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)jumpToBizWebviewWithAppID:(NSString *)appID
|
||||
Description:(NSString *)description
|
||||
tousrname:(NSString *)tousrname
|
||||
ExtMsg:(NSString *)extMsg {
|
||||
[WXApi registerApp:appID];
|
||||
JumpToBizWebviewReq *req = [[JumpToBizWebviewReq alloc]init];
|
||||
req.tousrname = tousrname;
|
||||
req.extMsg = extMsg;
|
||||
req.webType = WXMPWebviewType_Ad;
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)openUrl:(NSString *)url
|
||||
{
|
||||
OpenWebviewReq *req = [[OpenWebviewReq alloc] init];
|
||||
req.url = url;
|
||||
return [WXApi sendReq:req];
|
||||
}
|
||||
|
||||
+ (BOOL)chooseInvoice:(NSString *)appid
|
||||
cardSign:(NSString *)cardSign
|
||||
nonceStr:(NSString *)nonceStr
|
||||
signType:(NSString *)signType
|
||||
timestamp:(UInt32)timestamp
|
||||
{
|
||||
WXChooseInvoiceReq *chooseInvoiceReq = [[WXChooseInvoiceReq alloc] init];
|
||||
chooseInvoiceReq.appID = appid;
|
||||
chooseInvoiceReq.cardSign = cardSign;
|
||||
chooseInvoiceReq.nonceStr = nonceStr;
|
||||
chooseInvoiceReq.signType = signType;
|
||||
// chooseCardReq.cardType = @"INVOICE";
|
||||
chooseInvoiceReq.timeStamp = timestamp;
|
||||
// chooseCardReq.canMultiSelect = 1;
|
||||
return [WXApi sendReq:chooseInvoiceReq];
|
||||
}
|
||||
|
||||
@end
|
||||
55
ios/Handler/WXApiResponseHandler.h
Normal file
55
ios/Handler/WXApiResponseHandler.h
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// WXApiResponseManager.h
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "WXApiObject.h"
|
||||
|
||||
@interface WXApiResponseHandler : NSObject
|
||||
|
||||
+ (BOOL)respText:(NSString *)text;
|
||||
|
||||
+ (BOOL)respImageData:(NSData *)imageData
|
||||
MessageExt:(NSString *)messageExt
|
||||
Action:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respLinkURL:(NSString *)urlString
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respMusicURL:(NSString *)musicURL
|
||||
dataURL:(NSString *)dataURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respVideoURL:(NSString *)videoURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respEmotionData:(NSData *)emotionData
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respFileData:(NSData *)fileData
|
||||
fileExtension:(NSString *)extension
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
+ (BOOL)respAppContentData:(NSData *)data
|
||||
ExtInfo:(NSString *)info
|
||||
ExtURL:(NSString *)url
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage;
|
||||
|
||||
@end
|
||||
181
ios/Handler/WXApiResponseHandler.m
Normal file
181
ios/Handler/WXApiResponseHandler.m
Normal file
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// WXApiResponseManager.m
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXApi.h"
|
||||
#import "WXApiResponseHandler.h"
|
||||
#import "GetMessageFromWXResp+responseWithTextOrMediaMessage.h"
|
||||
#import "WXMediaMessage+messageConstruct.h"
|
||||
|
||||
@implementation WXApiResponseHandler
|
||||
|
||||
#pragma mark - Public Methods
|
||||
+ (BOOL)respText:(NSString *)text {
|
||||
GetMessageFromWXResp *resp = [GetMessageFromWXResp responseWithText:text
|
||||
OrMediaMessage:nil
|
||||
bText:YES];
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respImageData:(NSData *)imageData
|
||||
MessageExt:(NSString *)messageExt
|
||||
Action:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXImageObject *ext = [WXImageObject object];
|
||||
ext.imageData = imageData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:nil
|
||||
Description:nil
|
||||
Object:ext
|
||||
MessageExt:messageExt
|
||||
MessageAction:action
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respLinkURL:(NSString *)urlString
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXWebpageObject *ext = [WXWebpageObject object];
|
||||
ext.webpageUrl = urlString;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respMusicURL:(NSString *)musicURL
|
||||
dataURL:(NSString *)dataURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
message.title = title;
|
||||
message.description = description;
|
||||
[message setThumbImage:thumbImage];
|
||||
WXMusicObject *ext = [WXMusicObject object];
|
||||
ext.musicUrl = musicURL;
|
||||
ext.musicDataUrl = dataURL;
|
||||
|
||||
message.mediaObject = ext;
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respVideoURL:(NSString *)videoURL
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXVideoObject *ext = [WXVideoObject object];
|
||||
ext.videoUrl = videoURL;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respEmotionData:(NSData *)emotionData
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXEmoticonObject *ext = [WXEmoticonObject object];
|
||||
ext.emoticonData = emotionData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:nil
|
||||
Description:nil
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respFileData:(NSData *)fileData
|
||||
fileExtension:(NSString *)extension
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXFileObject *ext = [WXFileObject object];
|
||||
ext.fileExtension = extension;
|
||||
ext.fileData = fileData;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:nil
|
||||
MessageAction:nil
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
+ (BOOL)respAppContentData:(NSData *)data
|
||||
ExtInfo:(NSString *)info
|
||||
ExtURL:(NSString *)url
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage {
|
||||
WXAppExtendObject *ext = [WXAppExtendObject object];
|
||||
ext.extInfo = info;
|
||||
ext.url = url;
|
||||
ext.fileData = data;
|
||||
|
||||
WXMediaMessage *message = [WXMediaMessage messageWithTitle:title
|
||||
Description:description
|
||||
Object:ext
|
||||
MessageExt:messageExt
|
||||
MessageAction:action
|
||||
ThumbImage:thumbImage
|
||||
MediaTag:nil];
|
||||
|
||||
GetMessageFromWXResp* resp = [GetMessageFromWXResp responseWithText:nil
|
||||
OrMediaMessage:message
|
||||
bText:NO];
|
||||
|
||||
return [WXApi sendResp:resp];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// GetMessageFromWXResp+responseWithTextOrMediaMessage.h
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXApiObject.h"
|
||||
|
||||
@interface GetMessageFromWXResp (responseWithTextOrMediaMessage)
|
||||
|
||||
+ (GetMessageFromWXResp *)responseWithText:(NSString *)text
|
||||
OrMediaMessage:(WXMediaMessage *)message
|
||||
bText:(BOOL)bText;
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// GetMessageFromWXResp+responseWithTextOrMediaMessage.m
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "GetMessageFromWXResp+responseWithTextOrMediaMessage.h"
|
||||
|
||||
@implementation GetMessageFromWXResp (responseWithTextOrMediaMessage)
|
||||
|
||||
+ (GetMessageFromWXResp *)responseWithText:(NSString *)text
|
||||
OrMediaMessage:(WXMediaMessage *)message
|
||||
bText:(BOOL)bText {
|
||||
GetMessageFromWXResp *resp = [[GetMessageFromWXResp alloc] init];
|
||||
resp.bText = bText;
|
||||
if (bText)
|
||||
resp.text = text;
|
||||
else
|
||||
resp.message = message;
|
||||
return resp;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// SendMessageToWXReq+requestWithTextOrMediaMessage.h
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXApiObject.h"
|
||||
|
||||
@interface SendMessageToWXReq (requestWithTextOrMediaMessage)
|
||||
|
||||
+ (SendMessageToWXReq *)requestWithText:(NSString *)text
|
||||
OrMediaMessage:(WXMediaMessage *)message
|
||||
bText:(BOOL)bText
|
||||
InScene:(enum WXScene)scene;
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// SendMessageToWXReq+requestWithTextOrMediaMessage.m
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SendMessageToWXReq+requestWithTextOrMediaMessage.h"
|
||||
|
||||
@implementation SendMessageToWXReq (requestWithTextOrMediaMessage)
|
||||
|
||||
+ (SendMessageToWXReq *)requestWithText:(NSString *)text
|
||||
OrMediaMessage:(WXMediaMessage *)message
|
||||
bText:(BOOL)bText
|
||||
InScene:(enum WXScene)scene {
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = bText;
|
||||
req.scene = scene;
|
||||
if (bText)
|
||||
req.text = text;
|
||||
else
|
||||
req.message = message;
|
||||
return req;
|
||||
}
|
||||
|
||||
@end
|
||||
20
ios/Helper/WXMediaMessage+messageConstruct.h
Normal file
20
ios/Helper/WXMediaMessage+messageConstruct.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// WXMediaMessage+messageConstruct.h
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXApiObject.h"
|
||||
|
||||
@interface WXMediaMessage (messageConstruct)
|
||||
|
||||
+ (WXMediaMessage *)messageWithTitle:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
Object:(id)mediaObject
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
MediaTag:(NSString *)tagName;
|
||||
@end
|
||||
31
ios/Helper/WXMediaMessage+messageConstruct.m
Normal file
31
ios/Helper/WXMediaMessage+messageConstruct.m
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// WXMediaMessage+messageConstruct.m
|
||||
// SDKSample
|
||||
//
|
||||
// Created by Jeason on 15/7/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "WXMediaMessage+messageConstruct.h"
|
||||
|
||||
@implementation WXMediaMessage (messageConstruct)
|
||||
|
||||
+ (WXMediaMessage *)messageWithTitle:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
Object:(id)mediaObject
|
||||
MessageExt:(NSString *)messageExt
|
||||
MessageAction:(NSString *)action
|
||||
ThumbImage:(UIImage *)thumbImage
|
||||
MediaTag:(NSString *)tagName {
|
||||
WXMediaMessage *message = [WXMediaMessage message];
|
||||
message.title = title;
|
||||
message.description = description;
|
||||
message.mediaObject = mediaObject;
|
||||
message.messageExt = messageExt;
|
||||
message.messageAction = action;
|
||||
message.mediaTagName = tagName;
|
||||
[message setThumbImage:thumbImage];
|
||||
return message;
|
||||
}
|
||||
|
||||
@end
|
||||
18
ios/RNWechat.h
Normal file
18
ios/RNWechat.h
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTEventEmitter.h>
|
||||
|
||||
#import "WXApi.h"
|
||||
#import "WXApiRequestHandler.h"
|
||||
|
||||
#define RNWechatEventName @"RNWechatEvent"
|
||||
|
||||
#define RNWechatOperateSuccess @"true"
|
||||
#define RNWechatOperateFailed @"false"
|
||||
|
||||
@interface RNWechat : RCTEventEmitter <RCTBridgeModule, WXApiDelegate>
|
||||
|
||||
+ (void)registerApp:(NSString *)appId IsDebug:(BOOL)isDebug;
|
||||
|
||||
@end
|
||||
|
||||
244
ios/RNWechat.m
Normal file
244
ios/RNWechat.m
Normal file
@@ -0,0 +1,244 @@
|
||||
#import "RNWechat.h"
|
||||
#import "Utils.h"
|
||||
|
||||
#define ASSIGN_EMPTY_STRING(assign, string) \
|
||||
if (string != nil) { \
|
||||
assign = string; \
|
||||
} else { \
|
||||
assign = @""; \
|
||||
}
|
||||
|
||||
static NSString *const kOpenURLNotification = @"RCTOpenURLNotification";
|
||||
|
||||
@implementation RNWechat
|
||||
|
||||
static bool isWXApiRegisteSuccess = false;
|
||||
|
||||
+ (void)registerApp:(NSString *)appId IsDebug:(BOOL)isDebug
|
||||
{
|
||||
if(![appId isEqualToString:@""]) {
|
||||
if (isDebug) {
|
||||
[WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
|
||||
NSLog(@"WXApi: %@", log);
|
||||
}];
|
||||
}
|
||||
isWXApiRegisteSuccess = [WXApi registerApp:appId];
|
||||
if (isWXApiRegisteSuccess) {
|
||||
NSLog(@"WXApi register success. appId: %@", appId);
|
||||
} else {
|
||||
NSLog(@"WXApi register failed. appId: %@", appId);
|
||||
}
|
||||
} else {
|
||||
NSLog(@"There is no appId for WXApi.");
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)getOperateResult:(BOOL)isOperateSucc
|
||||
{
|
||||
return isOperateSucc ? RNWechatOperateSuccess : RNWechatOperateFailed;
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
// observe RCTLinking push notification
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(openURL:)
|
||||
name:kOpenURLNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (BOOL)openURL:(NSNotification *)aNotification
|
||||
{
|
||||
NSURL *aURL = [NSURL URLWithString:[aNotification userInfo][@"url"]];
|
||||
return [WXApi handleOpenURL:aURL delegate:self];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)supportedEvents
|
||||
{
|
||||
return @[RNWechatEventName];
|
||||
}
|
||||
|
||||
- (void)sendEvent:(id)body {
|
||||
[self sendEventWithName:RNWechatEventName body:body];
|
||||
}
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
{
|
||||
return dispatch_get_main_queue();
|
||||
}
|
||||
|
||||
+ (BOOL)requiresMainQueueSetup
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma react-native-methods
|
||||
RCT_REMAP_METHOD(isWXApiRegisteSuccess,
|
||||
isWXApiRegisteSuccessWithResolver:(RCTPromiseResolveBlock)resolve
|
||||
rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
resolve([RNWechat getOperateResult:isWXApiRegisteSuccess]);
|
||||
}
|
||||
|
||||
RCT_REMAP_METHOD(isWXAppInstalled,
|
||||
isWXAppInstalledWithResolver:(RCTPromiseResolveBlock)resolve
|
||||
rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
resolve([RNWechat getOperateResult:[WXApi isWXAppInstalled]]);
|
||||
}
|
||||
|
||||
RCT_REMAP_METHOD(sendAuthRequestScope,
|
||||
sendAuthRequestScope:(NSString *)scope
|
||||
State:(NSString *)state
|
||||
OpenID:(NSString *)openID
|
||||
Resolver:(RCTPromiseResolveBlock)resolve
|
||||
Rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
resolve([RNWechat getOperateResult:[WXApiRequestHandler sendAuthRequestScope:scope State:state OpenID:openID]]);
|
||||
}
|
||||
|
||||
RCT_REMAP_METHOD(sendText,
|
||||
sendText:(NSString *)text
|
||||
SceneType:(NSInteger)sceneType
|
||||
Resolver:(RCTPromiseResolveBlock)resolve
|
||||
Rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
resolve([RNWechat getOperateResult:[WXApiRequestHandler sendText:text InScene:(enum WXScene)sceneType]]);
|
||||
}
|
||||
|
||||
RCT_REMAP_METHOD(sendLinkURL,
|
||||
sendLinkURL:(NSString *)urlString
|
||||
Title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImageUrlString:(NSString *)thumbImageUrlString
|
||||
SceneType:(NSInteger)sceneType
|
||||
Resolver:(RCTPromiseResolveBlock)resolve
|
||||
Rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
UIImage *thumbImage = [Utils imageUrlString:thumbImageUrlString toImageWithSize:CGSizeMake(100.0, 100.0)];
|
||||
resolve([RNWechat getOperateResult:[WXApiRequestHandler
|
||||
sendLinkURL:urlString
|
||||
TagName:@""
|
||||
Title:title
|
||||
Description:description
|
||||
ThumbImage:thumbImage
|
||||
InScene:(enum WXScene)sceneType ]]);
|
||||
}
|
||||
|
||||
RCT_REMAP_METHOD(sendMiniProgramWebpageUrl,
|
||||
sendMiniProgramWebpageUrl:(NSString *)webpageUrl
|
||||
userName:(NSString *)userName
|
||||
path:(NSString *)path
|
||||
title:(NSString *)title
|
||||
Description:(NSString *)description
|
||||
ThumbImageUrlString:(NSString *)thumbImageUrlString
|
||||
hdImageUrlString:(NSString *)hdImageUrlString
|
||||
miniProgramType:(NSInteger)programType
|
||||
Resolver:(RCTPromiseResolveBlock)resolve
|
||||
Rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
// 小程序只支持会话分享
|
||||
UIImage *thumbImage = [Utils imageUrlString:thumbImageUrlString toImageWithSize:CGSizeMake(100.0, 100.0)];
|
||||
NSData *hdImageData = [Utils imageUrlStringToData:hdImageUrlString];
|
||||
resolve([RNWechat getOperateResult:[WXApiRequestHandler
|
||||
sendMiniProgramWebpageUrl:webpageUrl
|
||||
userName:userName path:path
|
||||
title:title
|
||||
Description:description
|
||||
ThumbImage:thumbImage
|
||||
hdImageData:hdImageData
|
||||
withShareTicket:YES
|
||||
miniProgramType:(WXMiniProgramType)programType
|
||||
InScene:WXSceneSession ]]);
|
||||
}
|
||||
|
||||
#pragma mark - WXApiDelegate
|
||||
- (void)onResp:(BaseResp *)resp {
|
||||
NSMutableDictionary *body = @{}.mutableCopy;
|
||||
body[@"errCode"] = @(resp.errCode);
|
||||
ASSIGN_EMPTY_STRING(body[@"errStr"], resp.errStr)
|
||||
|
||||
if ([resp isKindOfClass:[SendMessageToWXResp class]]) {
|
||||
// 发送文字
|
||||
SendMessageToWXResp *messageResp = (SendMessageToWXResp *)resp;
|
||||
body[@"eventType"] = @"SendMessageToWXResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"lang"], messageResp.lang)
|
||||
ASSIGN_EMPTY_STRING(body[@"country"], messageResp.country)
|
||||
} else if ([resp isKindOfClass:[SendAuthResp class]]) {
|
||||
// 发送验证请求
|
||||
SendAuthResp *authResp = (SendAuthResp *)resp;
|
||||
body[@"eventType"] = @"SendAuthResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"code"], authResp.code)
|
||||
ASSIGN_EMPTY_STRING(body[@"state"], authResp.state)
|
||||
ASSIGN_EMPTY_STRING(body[@"lang"], authResp.lang)
|
||||
ASSIGN_EMPTY_STRING(body[@"country"], authResp.country)
|
||||
} else if ([resp isKindOfClass:[AddCardToWXCardPackageResp class]]) {
|
||||
// 添加卡片到卡包
|
||||
AddCardToWXCardPackageResp *addCardResp = (AddCardToWXCardPackageResp *)resp;
|
||||
body[@"eventType"] = @"AddCardToWXCardPackageResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"cardAry"], addCardResp.cardAry)
|
||||
} else if ([resp isKindOfClass:[WXChooseCardResp class]]) {
|
||||
// 选择卡片
|
||||
WXChooseCardResp *chooseCardResp = (WXChooseCardResp *)resp;
|
||||
body[@"eventType"] = @"WXChooseCardResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"cardAry"], chooseCardResp.cardAry)
|
||||
} else if ([resp isKindOfClass:[WXChooseInvoiceResp class]]){
|
||||
// 选择发票
|
||||
WXChooseInvoiceResp *chooseInvoiceResp = (WXChooseInvoiceResp *)resp;
|
||||
body[@"eventType"] = @"WXChooseInvoiceResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"cardAry"], chooseInvoiceResp.cardAry)
|
||||
} else if ([resp isKindOfClass:[WXSubscribeMsgResp class]]){
|
||||
// 订阅消息
|
||||
WXSubscribeMsgResp *subscribeMsgResp = (WXSubscribeMsgResp *)resp;
|
||||
body[@"eventType"] = @"WXSubscribeMsgResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"templateId"], subscribeMsgResp.templateId)
|
||||
// subscribeMsgResp.scene
|
||||
ASSIGN_EMPTY_STRING(body[@"action"], subscribeMsgResp.action)
|
||||
ASSIGN_EMPTY_STRING(body[@"reserved"], subscribeMsgResp.reserved)
|
||||
ASSIGN_EMPTY_STRING(body[@"openId"], subscribeMsgResp.openId)
|
||||
} else if ([resp isKindOfClass:[WXLaunchMiniProgramResp class]]){
|
||||
// 启动小程序
|
||||
WXLaunchMiniProgramResp *launchMiniProgramResp = (WXLaunchMiniProgramResp *)resp;
|
||||
body[@"eventType"] = @"WXLaunchMiniProgramResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"extMsg"], launchMiniProgramResp.extMsg)
|
||||
} else if([resp isKindOfClass:[WXInvoiceAuthInsertResp class]]){
|
||||
WXInvoiceAuthInsertResp *invoiceAuthInsertResp = (WXInvoiceAuthInsertResp *)resp;
|
||||
body[@"eventType"] = @"WXInvoiceAuthInsertResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"wxOrderId"], invoiceAuthInsertResp.wxOrderId)
|
||||
} else if([resp isKindOfClass:[WXNontaxPayResp class]]){
|
||||
WXNontaxPayResp *nontaxPayResp = (WXNontaxPayResp *)resp;
|
||||
body[@"eventType"] = @"WXNontaxPayResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"wxOrderId"], nontaxPayResp.wxOrderId)
|
||||
} else if ([resp isKindOfClass:[WXPayInsuranceResp class]]){
|
||||
WXPayInsuranceResp *payInsuranceResp = (WXPayInsuranceResp *)resp;
|
||||
body[@"eventType"] = @"WXPayInsuranceResp";
|
||||
ASSIGN_EMPTY_STRING(body[@"wxOrderId"], payInsuranceResp.wxOrderId)
|
||||
}
|
||||
|
||||
[self sendEvent:body];
|
||||
}
|
||||
|
||||
- (void)onReq:(BaseReq *)req {
|
||||
// if ([req isKindOfClass:[GetMessageFromWXReq class]]) {
|
||||
// GetMessageFromWXReq *getMessageReq = (GetMessageFromWXReq *)req;
|
||||
// } else if ([req isKindOfClass:[ShowMessageFromWXReq class]]) {
|
||||
// ShowMessageFromWXReq *showMessageReq = (ShowMessageFromWXReq *)req;
|
||||
// } else if ([req isKindOfClass:[LaunchFromWXReq class]]) {
|
||||
// LaunchFromWXReq *launchReq = (LaunchFromWXReq *)req;
|
||||
// }
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
21
ios/RNWechat.podspec
Normal file
21
ios/RNWechat.podspec
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "RNWechat"
|
||||
s.version = "1.0.0"
|
||||
s.summary = "react native wechat"
|
||||
s.description = <<-DESC
|
||||
react native for wechat
|
||||
DESC
|
||||
s.homepage = ""
|
||||
s.license = "MIT"
|
||||
s.author = { "dongdayu" => "g592842897@gmail.com" }
|
||||
s.platform = :ios, "7.0"
|
||||
s.source = { :git => "https://github.com/yyyyu/react-native-wechat.git", :tag => "master" }
|
||||
s.source_files = "RNWechat.{h,m}"
|
||||
s.requires_arc = true
|
||||
|
||||
|
||||
s.dependency "React"
|
||||
s.dependency "WechatOpenSDK"
|
||||
|
||||
end
|
||||
331
ios/RNWechat.xcodeproj/project.pbxproj
Normal file
331
ios/RNWechat.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,331 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
362DF4D5204FE823009D01D3 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 362DF4D4204FE823009D01D3 /* Utils.m */; };
|
||||
368AFA5D204D29FB00ABB362 /* libWeChatSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 368AFA5A204D29FB00ABB362 /* libWeChatSDK.a */; };
|
||||
368AFA60204D399A00ABB362 /* WXApiRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 368AFA5F204D399A00ABB362 /* WXApiRequestHandler.m */; };
|
||||
368AFA66204D3A2400ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 368AFA65204D3A2400ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.m */; };
|
||||
368AFA69204D3A3000ABB362 /* WXMediaMessage+messageConstruct.m in Sources */ = {isa = PBXBuildFile; fileRef = 368AFA68204D3A3000ABB362 /* WXMediaMessage+messageConstruct.m */; };
|
||||
368AFA6B204D3A7E00ABB362 /* WXApiResponseHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 368AFA6A204D3A7E00ABB362 /* WXApiResponseHandler.m */; };
|
||||
368AFA6F204D3A8D00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 368AFA6E204D3A8D00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.m */; };
|
||||
B3E7B58A1CC2AC0600A0062D /* RNWechat.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNWechat.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
134814201AA4EA6300B7C361 /* libRNWechat.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNWechat.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
362DF4D4204FE823009D01D3 /* Utils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Utils.m; sourceTree = "<group>"; };
|
||||
362DF4D6204FEB38009D01D3 /* Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; };
|
||||
368AFA59204D29FB00ABB362 /* WechatAuthSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WechatAuthSDK.h; path = Wechat/WechatAuthSDK.h; sourceTree = "<group>"; };
|
||||
368AFA5A204D29FB00ABB362 /* libWeChatSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libWeChatSDK.a; path = Wechat/libWeChatSDK.a; sourceTree = "<group>"; };
|
||||
368AFA5B204D29FB00ABB362 /* WXApiObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WXApiObject.h; path = Wechat/WXApiObject.h; sourceTree = "<group>"; };
|
||||
368AFA5C204D29FB00ABB362 /* WXApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WXApi.h; path = Wechat/WXApi.h; sourceTree = "<group>"; };
|
||||
368AFA5E204D399500ABB362 /* WXApiRequestHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXApiRequestHandler.h; sourceTree = "<group>"; };
|
||||
368AFA5F204D399A00ABB362 /* WXApiRequestHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXApiRequestHandler.m; sourceTree = "<group>"; };
|
||||
368AFA64204D3A1F00ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SendMessageToWXReq+requestWithTextOrMediaMessage.h"; sourceTree = "<group>"; };
|
||||
368AFA65204D3A2400ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SendMessageToWXReq+requestWithTextOrMediaMessage.m"; sourceTree = "<group>"; };
|
||||
368AFA67204D3A2D00ABB362 /* WXMediaMessage+messageConstruct.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WXMediaMessage+messageConstruct.h"; sourceTree = "<group>"; };
|
||||
368AFA68204D3A3000ABB362 /* WXMediaMessage+messageConstruct.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WXMediaMessage+messageConstruct.m"; sourceTree = "<group>"; };
|
||||
368AFA6A204D3A7E00ABB362 /* WXApiResponseHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXApiResponseHandler.m; sourceTree = "<group>"; };
|
||||
368AFA6C204D3A8100ABB362 /* WXApiResponseHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXApiResponseHandler.h; sourceTree = "<group>"; };
|
||||
368AFA6D204D3A8B00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GetMessageFromWXResp+responseWithTextOrMediaMessage.h"; sourceTree = "<group>"; };
|
||||
368AFA6E204D3A8D00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "GetMessageFromWXResp+responseWithTextOrMediaMessage.m"; sourceTree = "<group>"; };
|
||||
B3E7B5881CC2AC0600A0062D /* RNWechat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNWechat.h; sourceTree = "<group>"; };
|
||||
B3E7B5891CC2AC0600A0062D /* RNWechat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNWechat.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
368AFA5D204D29FB00ABB362 /* libWeChatSDK.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
134814211AA4EA7D00B7C361 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
134814201AA4EA6300B7C361 /* libRNWechat.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
36751C7D204EA21300E6C291 /* Handler */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
368AFA5E204D399500ABB362 /* WXApiRequestHandler.h */,
|
||||
368AFA5F204D399A00ABB362 /* WXApiRequestHandler.m */,
|
||||
368AFA6C204D3A8100ABB362 /* WXApiResponseHandler.h */,
|
||||
368AFA6A204D3A7E00ABB362 /* WXApiResponseHandler.m */,
|
||||
);
|
||||
path = Handler;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
36751C7E204EA21C00E6C291 /* Helper */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
368AFA64204D3A1F00ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.h */,
|
||||
368AFA65204D3A2400ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.m */,
|
||||
368AFA6D204D3A8B00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.h */,
|
||||
368AFA6E204D3A8D00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.m */,
|
||||
368AFA67204D3A2D00ABB362 /* WXMediaMessage+messageConstruct.h */,
|
||||
368AFA68204D3A3000ABB362 /* WXMediaMessage+messageConstruct.m */,
|
||||
);
|
||||
path = Helper;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
368AFA58204D29DF00ABB362 /* Wechat */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
368AFA59204D29FB00ABB362 /* WechatAuthSDK.h */,
|
||||
368AFA5C204D29FB00ABB362 /* WXApi.h */,
|
||||
368AFA5B204D29FB00ABB362 /* WXApiObject.h */,
|
||||
368AFA5A204D29FB00ABB362 /* libWeChatSDK.a */,
|
||||
);
|
||||
name = Wechat;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
58B511D21A9E6C8500147676 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B3E7B5881CC2AC0600A0062D /* RNWechat.h */,
|
||||
B3E7B5891CC2AC0600A0062D /* RNWechat.m */,
|
||||
362DF4D6204FEB38009D01D3 /* Utils.h */,
|
||||
362DF4D4204FE823009D01D3 /* Utils.m */,
|
||||
36751C7D204EA21300E6C291 /* Handler */,
|
||||
36751C7E204EA21C00E6C291 /* Helper */,
|
||||
368AFA58204D29DF00ABB362 /* Wechat */,
|
||||
134814211AA4EA7D00B7C361 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
58B511DA1A9E6C8500147676 /* RNWechat */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNWechat" */;
|
||||
buildPhases = (
|
||||
58B511D71A9E6C8500147676 /* Sources */,
|
||||
58B511D81A9E6C8500147676 /* Frameworks */,
|
||||
58B511D91A9E6C8500147676 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = RNWechat;
|
||||
productName = RCTDataManager;
|
||||
productReference = 134814201AA4EA6300B7C361 /* libRNWechat.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
58B511D31A9E6C8500147676 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0830;
|
||||
ORGANIZATIONNAME = Facebook;
|
||||
TargetAttributes = {
|
||||
58B511DA1A9E6C8500147676 = {
|
||||
CreatedOnToolsVersion = 6.1.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNWechat" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 58B511D21A9E6C8500147676;
|
||||
productRefGroup = 58B511D21A9E6C8500147676;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
58B511DA1A9E6C8500147676 /* RNWechat */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
58B511D71A9E6C8500147676 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
368AFA69204D3A3000ABB362 /* WXMediaMessage+messageConstruct.m in Sources */,
|
||||
368AFA6B204D3A7E00ABB362 /* WXApiResponseHandler.m in Sources */,
|
||||
368AFA6F204D3A8D00ABB362 /* GetMessageFromWXResp+responseWithTextOrMediaMessage.m in Sources */,
|
||||
368AFA66204D3A2400ABB362 /* SendMessageToWXReq+requestWithTextOrMediaMessage.m in Sources */,
|
||||
368AFA60204D399A00ABB362 /* WXApiRequestHandler.m in Sources */,
|
||||
362DF4D5204FE823009D01D3 /* Utils.m in Sources */,
|
||||
B3E7B58A1CC2AC0600A0062D /* RNWechat.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
58B511ED1A9E6C8500147676 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
58B511EE1A9E6C8500147676 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
58B511F01A9E6C8500147676 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/Wechat",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Wechat",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = RNWechat;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
58B511F11A9E6C8500147676 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/Wechat",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Wechat",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = RNWechat;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNWechat" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
58B511ED1A9E6C8500147676 /* Debug */,
|
||||
58B511EE1A9E6C8500147676 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNWechat" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
58B511F01A9E6C8500147676 /* Debug */,
|
||||
58B511F11A9E6C8500147676 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
||||
}
|
||||
24
ios/Utils.h
Normal file
24
ios/Utils.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Utils.h
|
||||
// RNWechat
|
||||
//
|
||||
// Created by dayu dong on 07/03/2018.
|
||||
// Copyright © 2018 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Utils_h
|
||||
#define Utils_h
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface Utils : NSObject
|
||||
|
||||
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)size;
|
||||
|
||||
+ (NSData *)imageUrlStringToData:(NSString *)imageUrlString;
|
||||
|
||||
+ (UIImage *)imageUrlString:(NSString *)imageUrlString toImageWithSize:(CGSize)size;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* Utils_h */
|
||||
45
ios/Utils.m
Normal file
45
ios/Utils.m
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Utils.m
|
||||
// RNWechat
|
||||
//
|
||||
// Created by dayu dong on 07/03/2018.
|
||||
// Copyright © 2018 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Utils.h"
|
||||
|
||||
@implementation Utils
|
||||
|
||||
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize
|
||||
{
|
||||
// UIGraphicsBeginImageContext(newSize);
|
||||
// In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution).
|
||||
// Pass 1.0 to force exact pixel size.
|
||||
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
|
||||
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
|
||||
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return newImage;
|
||||
}
|
||||
|
||||
+ (NSData *)imageUrlStringToData:(NSString *)imageUrlString
|
||||
{
|
||||
if ([imageUrlString isEqualToString:@""]) {
|
||||
return nil;
|
||||
}
|
||||
NSURL *imageUrl = [NSURL URLWithString:imageUrlString];
|
||||
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageUrl];
|
||||
return imageData;
|
||||
}
|
||||
|
||||
+ (UIImage *)imageUrlString:(NSString *)imageUrlString toImageWithSize:(CGSize)size
|
||||
{
|
||||
NSData *imageData = [Utils imageUrlStringToData:imageUrlString];
|
||||
UIImage *image = nil;
|
||||
if (imageData != nil) {
|
||||
image = [Utils imageWithImage:[UIImage imageWithData:imageData] scaledToSize:size];
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@end
|
||||
89
ios/Wechat/README.txt
Normal file
89
ios/Wechat/README.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
重要!
|
||||
SDK1.8.2
|
||||
1. SDK增加开发票授权 WXInvoiceAuthInsert
|
||||
2. SDK增加非税接口 WXNontaxPay
|
||||
3. SDK增加医保接口 WXPayInsurance
|
||||
4. 更换MTA库
|
||||
|
||||
SDK1.8.1
|
||||
1. SDK打开小程序支持指定版本(体验,开发,正式版)
|
||||
2. SDK分享小程序支持指定版本(体验,开发,正式版)
|
||||
3. SDK支持输出log日志
|
||||
|
||||
SDK1.8.0
|
||||
1. SDK支持打开小程序
|
||||
2. SDK分享小程序支持shareTicket
|
||||
|
||||
SDK1.7.9
|
||||
1. SDK订阅一次性消息
|
||||
|
||||
SDK1.7.8
|
||||
1 SDK分享小程序支持大图
|
||||
|
||||
SDK1.7.7
|
||||
1 增加SDK分享小程序
|
||||
2 增加选择发票接口
|
||||
|
||||
SDK1.7.6
|
||||
1. 提高稳定性
|
||||
1 修复mta崩溃
|
||||
2 新增接口支持开发者关闭mta数据统计上报
|
||||
|
||||
SDK1.7.5
|
||||
1. 提高稳定性
|
||||
2. 加快registerApp接口启动速度
|
||||
|
||||
SDK1.7.4
|
||||
1. 更新支持iOS启用 ATS(App Transport Security)
|
||||
2. 需要在工程中链接CFNetwork.framework
|
||||
3. 在工程配置中的”Other Linker Flags”中加入”-Objc -all_load”
|
||||
|
||||
SDK1.7.3
|
||||
1. 增强稳定性,适配iOS10
|
||||
2. 修复小于32K的jpg格式缩略图设置失败的问题
|
||||
|
||||
SDK1.7.2
|
||||
1. 修复因CTTeleponyNetworkInfo引起的崩溃问题
|
||||
|
||||
SDK1.7.1
|
||||
1. 支持兼容ipv6(提升稳定性)
|
||||
2. xCode Version 7.3.1 (7D1014) 编译
|
||||
|
||||
SDK1.7
|
||||
1. 支持兼容ipv6
|
||||
2. 修复若干问题增强稳定性
|
||||
|
||||
SDK1.6.3
|
||||
1. xCode7.2 构建的sdk包。
|
||||
2. 请使用xCode7.2进行编译。
|
||||
3. 需要在Build Phases中Link Security.framework
|
||||
4. 修复若干小问题。
|
||||
|
||||
SDK1.6.2
|
||||
1、xCode7.1 构建的sdk包
|
||||
2、请使用xCode7.1进行编译
|
||||
|
||||
SDK1.6.1
|
||||
1、修复armv7s下,bitcode可能编译不过
|
||||
2、解决warning
|
||||
|
||||
SDK1.6
|
||||
1、iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装。
|
||||
受此影响,当你的应用在iOS 9中需要使用微信SDK的相关能力(分享、收藏、支付、登录等)时,需要在“Info.plist”里增加如下代码:
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>weixin</string>
|
||||
</array>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
2、开发者需要在工程中链接上 CoreTelephony.framework
|
||||
3、解决bitcode编译不过问题
|
||||
|
||||
SDK1.5
|
||||
1、废弃safeSendReq:接口,使用sendReq:即可。
|
||||
2、新增+(BOOL) sendAuthReq:(SendAuthReq*) req viewController : (UIViewController*) viewController delegate:(id<WXApiDelegate>) delegate;
|
||||
支持未安装微信情况下Auth,具体见WXApi.h接口描述
|
||||
3、微信开放平台新增了微信模块用户统计功能,便于开发者统计微信功能模块的用户使用和活跃情况。开发者需要在工程中链接上:SystemConfiguration.framework,libz.dylib,libsqlite3.0.dylib。
|
||||
193
ios/Wechat/WXApi.h
Normal file
193
ios/Wechat/WXApi.h
Normal file
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// WXApi.h
|
||||
// 所有Api接口
|
||||
//
|
||||
// Created by Wechat on 12-2-28.
|
||||
// Copyright (c) 2012年 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "WXApiObject.h"
|
||||
|
||||
|
||||
#pragma mark - WXApiDelegate
|
||||
/*! @brief 接收并处理来自微信终端程序的事件消息
|
||||
*
|
||||
* 接收并处理来自微信终端程序的事件消息,期间微信界面会切换到第三方应用程序。
|
||||
* WXApiDelegate 会在handleOpenURL:delegate:中使用并触发。
|
||||
*/
|
||||
@protocol WXApiDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/*! @brief 收到一个来自微信的请求,第三方应用程序处理完后调用sendResp向微信发送结果
|
||||
*
|
||||
* 收到一个来自微信的请求,异步处理完成后必须调用sendResp发送处理结果给微信。
|
||||
* 可能收到的请求有GetMessageFromWXReq、ShowMessageFromWXReq等。
|
||||
* @param req 具体请求内容,是自动释放的
|
||||
*/
|
||||
-(void) onReq:(BaseReq*)req;
|
||||
|
||||
|
||||
|
||||
/*! @brief 发送一个sendReq后,收到微信的回应
|
||||
*
|
||||
* 收到一个来自微信的处理结果。调用一次sendReq后会收到onResp。
|
||||
* 可能收到的处理结果有SendMessageToWXResp、SendAuthResp等。
|
||||
* @param resp具体的回应内容,是自动释放的
|
||||
*/
|
||||
-(void) onResp:(BaseResp*)resp;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXApiLogDelegate
|
||||
|
||||
@protocol WXApiLogDelegate <NSObject>
|
||||
|
||||
-(void) onLog:(NSString*)log logLevel:(WXLogLevel)level;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXApi
|
||||
|
||||
/*! @brief 微信Api接口函数类
|
||||
*
|
||||
* 该类封装了微信终端SDK的所有接口
|
||||
*/
|
||||
@interface WXApi : NSObject
|
||||
|
||||
/*! @brief WXApi的成员函数,向微信终端程序注册第三方应用。
|
||||
*
|
||||
* 需要在每次启动第三方应用程序时调用。第一次调用后,会在微信的可用应用列表中出现,默认开启MTA数据上报。
|
||||
* iOS7及以上系统需要调起一次微信才会出现在微信的可用应用列表中。
|
||||
* @attention 请保证在主线程中调用此函数
|
||||
* @param appid 微信开发者ID
|
||||
* @param typeFlag 应用支持打开的文件类型
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) registerApp:(NSString *)appid;
|
||||
|
||||
/*! @brief WXApi的成员函数,向微信终端程序注册第三方应用。
|
||||
*
|
||||
* 需要在每次启动第三方应用程序时调用。第一次调用后,会在微信的可用应用列表中出现。
|
||||
* iOS7及以上系统需要调起一次微信才会出现在微信的可用应用列表中。
|
||||
* @attention 请保证在主线程中调用此函数
|
||||
* @param appid 微信开发者ID
|
||||
* @param isEnableMTA 是否支持MTA数据上报
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) registerApp:(NSString *)appid enableMTA:(BOOL)isEnableMTA;
|
||||
|
||||
|
||||
/*! @brief WXApi的成员函数,向微信终端程序注册应用支持打开的文件类型。
|
||||
*
|
||||
* 需要在每次启动第三方应用程序时调用。调用后并第一次成功分享数据到微信后,会在微信的可用应用列表中出现。
|
||||
* @see registerApp
|
||||
* @param typeFlag 应用支持打开的数据类型, enAppSupportContentFlag枚举类型 “|” 操作后结果
|
||||
*/
|
||||
+(void) registerAppSupportContentFlag:(UInt64)typeFlag;
|
||||
|
||||
|
||||
|
||||
/*! @brief 处理微信通过URL启动App时传递的数据
|
||||
*
|
||||
* 需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用。
|
||||
* @param url 微信启动第三方应用时传递过来的URL
|
||||
* @param delegate WXApiDelegate对象,用来接收微信触发的消息。
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) handleOpenURL:(NSURL *) url delegate:(id<WXApiDelegate>) delegate;
|
||||
|
||||
|
||||
|
||||
/*! @brief 检查微信是否已被用户安装
|
||||
*
|
||||
* @return 微信已安装返回YES,未安装返回NO。
|
||||
*/
|
||||
+(BOOL) isWXAppInstalled;
|
||||
|
||||
|
||||
|
||||
/*! @brief 判断当前微信的版本是否支持OpenApi
|
||||
*
|
||||
* @return 支持返回YES,不支持返回NO。
|
||||
*/
|
||||
+(BOOL) isWXAppSupportApi;
|
||||
|
||||
|
||||
|
||||
/*! @brief 获取微信的itunes安装地址
|
||||
*
|
||||
* @return 微信的安装地址字符串。
|
||||
*/
|
||||
+(NSString *) getWXAppInstallUrl;
|
||||
|
||||
|
||||
|
||||
/*! @brief 获取当前微信SDK的版本号
|
||||
*
|
||||
* @return 返回当前微信SDK的版本号
|
||||
*/
|
||||
+(NSString *) getApiVersion;
|
||||
|
||||
|
||||
|
||||
/*! @brief 打开微信
|
||||
*
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) openWXApp;
|
||||
|
||||
|
||||
|
||||
/*! @brief 发送请求到微信,等待微信返回onResp
|
||||
*
|
||||
* 函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp。支持以下类型
|
||||
* SendAuthReq、SendMessageToWXReq、PayReq等。
|
||||
* @param req 具体的发送请求,在调用函数后,请自己释放。
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) sendReq:(BaseReq*)req;
|
||||
|
||||
/*! @brief 发送Auth请求到微信,支持用户没安装微信,等待微信返回onResp
|
||||
*
|
||||
* 函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp。支持SendAuthReq类型。
|
||||
* @param req 具体的发送请求,在调用函数后,请自己释放。
|
||||
* @param viewController 当前界面对象。
|
||||
* @param delegate WXApiDelegate对象,用来接收微信触发的消息。
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) sendAuthReq:(SendAuthReq*)req viewController:(UIViewController*)viewController delegate:(id<WXApiDelegate>)delegate;
|
||||
|
||||
|
||||
/*! @brief 收到微信onReq的请求,发送对应的应答给微信,并切换到微信界面
|
||||
*
|
||||
* 函数调用后,会切换到微信的界面。第三方应用程序收到微信onReq的请求,异步处理该请求,完成后必须调用该函数。可能发送的相应有
|
||||
* GetMessageFromWXResp、ShowMessageFromWXResp等。
|
||||
* @param resp 具体的应答内容,调用函数后,请自己释放
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
+(BOOL) sendResp:(BaseResp*)resp;
|
||||
|
||||
|
||||
/*! @brief WXApi的成员函数,接受微信的log信息。byBlock
|
||||
注意1:SDK会强引用这个block,注意不要导致内存泄漏,注意不要导致内存泄漏
|
||||
注意2:调用过一次startLog by block之后,如果再调用一次任意方式的startLoad,会释放上一次logBlock,不再回调上一个logBlock
|
||||
*
|
||||
* @param level 打印log的级别
|
||||
* @param logBlock 打印log的回调block
|
||||
*/
|
||||
+(void) startLogByLevel:(WXLogLevel)level logBlock:(WXLogBolock)logBlock;
|
||||
|
||||
/*! @brief WXApi的成员函数,接受微信的log信息。byDelegate
|
||||
注意1:sdk会弱引用这个delegate,这里可加任意对象为代理,不需要与WXApiDelegate同一个对象
|
||||
注意2:调用过一次startLog by delegate之后,再调用一次任意方式的startLoad,不会再回调上一个logDelegate对象
|
||||
* @param level 打印log的级别
|
||||
* @param logDelegate 打印log的回调代理,
|
||||
*/
|
||||
+ (void)startLogByLevel:(WXLogLevel)level logDelegate:(id<WXApiLogDelegate>)logDelegate;
|
||||
|
||||
/*! @brief 停止打印log,会清理block或者delegate为空,释放block
|
||||
* @param
|
||||
*/
|
||||
+ (void)stopLog;
|
||||
@end
|
||||
914
ios/Wechat/WXApiObject.h
Normal file
914
ios/Wechat/WXApiObject.h
Normal file
@@ -0,0 +1,914 @@
|
||||
//
|
||||
// MMApiObject.h
|
||||
// Api对象,包含所有接口和对象数据定义
|
||||
//
|
||||
// Created by Wechat on 12-2-28.
|
||||
// Copyright (c) 2012年 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
/*! @brief 错误码
|
||||
*
|
||||
*/
|
||||
enum WXErrCode {
|
||||
WXSuccess = 0, /**< 成功 */
|
||||
WXErrCodeCommon = -1, /**< 普通错误类型 */
|
||||
WXErrCodeUserCancel = -2, /**< 用户点击取消并返回 */
|
||||
WXErrCodeSentFail = -3, /**< 发送失败 */
|
||||
WXErrCodeAuthDeny = -4, /**< 授权失败 */
|
||||
WXErrCodeUnsupport = -5, /**< 微信不支持 */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! @brief 请求发送场景
|
||||
*
|
||||
*/
|
||||
enum WXScene {
|
||||
WXSceneSession = 0, /**< 聊天界面 */
|
||||
WXSceneTimeline = 1, /**< 朋友圈 */
|
||||
WXSceneFavorite = 2, /**< 收藏 */
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum WXAPISupport {
|
||||
WXAPISupportSession = 0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! @brief 跳转profile类型
|
||||
*
|
||||
*/
|
||||
enum WXBizProfileType{
|
||||
WXBizProfileType_Normal = 0, //**< 普通公众号 */
|
||||
WXBizProfileType_Device = 1, //**< 硬件公众号 */
|
||||
};
|
||||
|
||||
/*! @brief 分享小程序类型
|
||||
*
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, WXMiniProgramType){
|
||||
WXMiniProgramTypeRelease = 0, //**< 正式版 */
|
||||
WXMiniProgramTypeTest = 1, //**< 开发版 */
|
||||
WXMiniProgramTypePreview = 2, //**< 体验版 */
|
||||
};
|
||||
|
||||
/*! @brief 跳转mp网页类型
|
||||
*
|
||||
*/
|
||||
enum WXMPWebviewType {
|
||||
WXMPWebviewType_Ad = 0, /**< 广告网页 **/
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! @brief 应用支持接收微信的文件类型
|
||||
*
|
||||
*/
|
||||
typedef NS_ENUM(UInt64, enAppSupportContentFlag)
|
||||
{
|
||||
MMAPP_SUPPORT_NOCONTENT = 0x0,
|
||||
MMAPP_SUPPORT_TEXT = 0x1,
|
||||
MMAPP_SUPPORT_PICTURE = 0x2,
|
||||
MMAPP_SUPPORT_LOCATION = 0x4,
|
||||
MMAPP_SUPPORT_VIDEO = 0x8,
|
||||
MMAPP_SUPPORT_AUDIO = 0x10,
|
||||
MMAPP_SUPPORT_WEBPAGE = 0x20,
|
||||
|
||||
// Suport File Type
|
||||
MMAPP_SUPPORT_DOC = 0x40, // doc
|
||||
MMAPP_SUPPORT_DOCX = 0x80, // docx
|
||||
MMAPP_SUPPORT_PPT = 0x100, // ppt
|
||||
MMAPP_SUPPORT_PPTX = 0x200, // pptx
|
||||
MMAPP_SUPPORT_XLS = 0x400, // xls
|
||||
MMAPP_SUPPORT_XLSX = 0x800, // xlsx
|
||||
MMAPP_SUPPORT_PDF = 0x1000, // pdf
|
||||
};
|
||||
|
||||
/*! @brief log的级别
|
||||
*
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger,WXLogLevel){
|
||||
WXLogLevelNormal = 0, // 打印日常的日志
|
||||
WXLogLevelDetail = 1, // 打印详细的日志
|
||||
};
|
||||
|
||||
|
||||
/*! @brief 打印回调的block
|
||||
*
|
||||
*/
|
||||
typedef void(^WXLogBolock)(NSString * log);
|
||||
|
||||
#pragma mark - BaseReq
|
||||
/*! @brief 该类为微信终端SDK所有请求类的基类
|
||||
*
|
||||
*/
|
||||
@interface BaseReq : NSObject
|
||||
|
||||
/** 请求类型 */
|
||||
@property (nonatomic, assign) int type;
|
||||
/** 由用户微信号和AppID组成的唯一标识,发送请求时第三方程序必须填写,用于校验微信用户是否换号登录*/
|
||||
@property (nonatomic, retain) NSString* openID;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - BaseResp
|
||||
/*! @brief 该类为微信终端SDK所有响应类的基类
|
||||
*
|
||||
*/
|
||||
@interface BaseResp : NSObject
|
||||
/** 错误码 */
|
||||
@property (nonatomic, assign) int errCode;
|
||||
/** 错误提示字符串 */
|
||||
@property (nonatomic, retain) NSString *errStr;
|
||||
/** 响应类型 */
|
||||
@property (nonatomic, assign) int type;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXMediaMessage
|
||||
@class WXMediaMessage;
|
||||
|
||||
#pragma mark - SendAuthReq
|
||||
/*! @brief 第三方程序向微信终端请求认证的消息结构
|
||||
*
|
||||
* 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,
|
||||
* 向微信终端发送一个SendAuthReq消息结构。微信终端处理完后会向第三方程序发送一个处理结果。
|
||||
* @see SendAuthResp
|
||||
*/
|
||||
@interface SendAuthReq : BaseReq
|
||||
/** 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,向微信终端发送一个SendAuthReq消息结构。微信终端处理完后会向第三方程序发送一个处理结果。
|
||||
* @see SendAuthResp
|
||||
* @note scope字符串长度不能超过1K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* scope;
|
||||
/** 第三方程序本身用来标识其请求的唯一性,最后跳转回第三方程序时,由微信终端回传。
|
||||
* @note state字符串长度不能超过1K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* state;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - SendAuthResp
|
||||
/*! @brief 微信处理完第三方程序的认证和权限申请后向第三方程序回送的处理结果。
|
||||
*
|
||||
* 第三方程序要向微信申请认证,并请求某些权限,需要调用WXApi的sendReq成员函数,向微信终端发送一个SendAuthReq消息结构。
|
||||
* 微信终端处理完后会向第三方程序发送一个SendAuthResp。
|
||||
* @see onResp
|
||||
*/
|
||||
@interface SendAuthResp : BaseResp
|
||||
@property (nonatomic, retain) NSString* code;
|
||||
/** 第三方程序发送时用来标识其请求的唯一性的标志,由第三方程序调用sendReq时传入,由微信终端回传
|
||||
* @note state字符串长度不能超过1K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* state;
|
||||
@property (nonatomic, retain) NSString* lang;
|
||||
@property (nonatomic, retain) NSString* country;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - SendMessageToWXReq
|
||||
/*! @brief 第三方程序发送消息至微信终端程序的消息结构体
|
||||
*
|
||||
* 第三方程序向微信发送信息需要传入SendMessageToWXReq结构体,信息类型包括文本消息和多媒体消息,
|
||||
* 分别对应于text和message成员。调用该方法后,微信处理完信息会向第三方程序发送一个处理结果。
|
||||
* @see SendMessageToWXResp
|
||||
*/
|
||||
@interface SendMessageToWXReq : BaseReq
|
||||
/** 发送消息的文本内容
|
||||
* @note 文本长度必须大于0且小于10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* text;
|
||||
/** 发送消息的多媒体内容
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@property (nonatomic, retain) WXMediaMessage* message;
|
||||
/** 发送消息的类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */
|
||||
@property (nonatomic, assign) BOOL bText;
|
||||
/** 发送的目标场景,可以选择发送到会话(WXSceneSession)或者朋友圈(WXSceneTimeline)。 默认发送到会话。
|
||||
* @see WXScene
|
||||
*/
|
||||
@property (nonatomic, assign) int scene;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - SendMessageToWXResp
|
||||
/*! @brief 微信终端向第三方程序返回的SendMessageToWXReq处理结果。
|
||||
*
|
||||
* 第三方程序向微信终端发送SendMessageToWXReq后,微信发送回来的处理结果,该结果用SendMessageToWXResp表示。
|
||||
*/
|
||||
@interface SendMessageToWXResp : BaseResp
|
||||
@property(nonatomic, retain) NSString* lang;
|
||||
@property(nonatomic, retain) NSString* country;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - GetMessageFromWXReq
|
||||
/*! @brief 微信终端向第三方程序请求提供内容的消息结构体。
|
||||
*
|
||||
* 微信终端向第三方程序请求提供内容,微信终端会向第三方程序发送GetMessageFromWXReq消息结构体,
|
||||
* 需要第三方程序调用sendResp返回一个GetMessageFromWXResp消息结构体。
|
||||
*/
|
||||
@interface GetMessageFromWXReq : BaseReq
|
||||
@property (nonatomic, retain) NSString* lang;
|
||||
@property (nonatomic, retain) NSString* country;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - GetMessageFromWXResp
|
||||
/*! @brief 微信终端向第三方程序请求提供内容,第三方程序向微信终端返回的消息结构体。
|
||||
*
|
||||
* 微信终端向第三方程序请求提供内容,第三方程序调用sendResp向微信终端返回一个GetMessageFromWXResp消息结构体。
|
||||
*/
|
||||
@interface GetMessageFromWXResp : BaseResp
|
||||
/** 向微信终端提供的文本内容
|
||||
@note 文本长度必须大于0且小于10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* text;
|
||||
/** 向微信终端提供的多媒体内容。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@property (nonatomic, retain) WXMediaMessage* message;
|
||||
/** 向微信终端提供内容的消息类型,包括文本消息和多媒体消息两种,两者只能选择其一,不能同时发送文本和多媒体消息 */
|
||||
@property (nonatomic, assign) BOOL bText;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - ShowMessageFromWXReq
|
||||
/*! @brief 微信通知第三方程序,要求第三方程序显示的消息结构体。
|
||||
*
|
||||
* 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。
|
||||
* 第三方程序处理完内容后调用sendResp向微信终端发送ShowMessageFromWXResp。
|
||||
*/
|
||||
@interface ShowMessageFromWXReq : BaseReq
|
||||
/** 微信终端向第三方程序发送的要求第三方程序处理的多媒体内容
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@property (nonatomic, retain) WXMediaMessage* message;
|
||||
@property (nonatomic, retain) NSString* lang;
|
||||
@property (nonatomic, retain) NSString* country;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - ShowMessageFromWXResp
|
||||
/*! @brief 微信通知第三方程序,要求第三方程序显示或处理某些消息,第三方程序处理完后向微信终端发送的处理结果。
|
||||
*
|
||||
* 微信需要通知第三方程序显示或处理某些内容时,会向第三方程序发送ShowMessageFromWXReq消息结构体。
|
||||
* 第三方程序处理完内容后调用sendResp向微信终端发送ShowMessageFromWXResp。
|
||||
*/
|
||||
@interface ShowMessageFromWXResp : BaseResp
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - LaunchFromWXReq
|
||||
/*! @brief 微信终端打开第三方程序携带的消息结构体
|
||||
*
|
||||
* 微信向第三方发送的结构体,第三方不需要返回
|
||||
*/
|
||||
@interface LaunchFromWXReq : BaseReq
|
||||
@property (nonatomic, retain) WXMediaMessage* message;
|
||||
@property (nonatomic, retain) NSString* lang;
|
||||
@property (nonatomic, retain) NSString* country;
|
||||
@end
|
||||
|
||||
#pragma mark - OpenTempSessionReq
|
||||
/* ! @brief 第三方通知微信,打开临时会话
|
||||
*
|
||||
* 第三方通知微信,打开临时会话
|
||||
*/
|
||||
@interface OpenTempSessionReq : BaseReq
|
||||
/** 需要打开的用户名
|
||||
* @attention 长度不能超过512字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* username;
|
||||
/** 开发者自定义参数,拉起临时会话后会发给开发者后台,可以用于识别场景
|
||||
* @attention 长度不能超过32位
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* sessionFrom;
|
||||
@end
|
||||
|
||||
#pragma mark - OpenTempSessionResp
|
||||
/*! @brief 微信终端向第三方程序返回的OpenTempSessionReq处理结果。
|
||||
*
|
||||
* 第三方程序向微信终端发送OpenTempSessionReq后,微信发送回来的处理结果,该结果用OpenTempSessionResp表示。
|
||||
*/
|
||||
@interface OpenTempSessionResp : BaseResp
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OpenWebviewReq
|
||||
/* ! @brief 第三方通知微信启动内部浏览器,打开指定网页
|
||||
*
|
||||
* 第三方通知微信启动内部浏览器,打开指定Url对应的网页
|
||||
*/
|
||||
@interface OpenWebviewReq : BaseReq
|
||||
/** 需要打开的网页对应的Url
|
||||
* @attention 长度不能超过1024
|
||||
*/
|
||||
@property(nonatomic,retain)NSString* url;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OpenWebviewResp
|
||||
/*! @brief 微信终端向第三方程序返回的OpenWebviewReq处理结果
|
||||
*
|
||||
* 第三方程序向微信终端发送OpenWebviewReq后,微信发送回来的处理结果,该结果用OpenWebviewResp表示
|
||||
*/
|
||||
@interface OpenWebviewResp : BaseResp
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OpenRankListReq
|
||||
/* ! @brief 第三方通知微信,打开硬件排行榜
|
||||
*
|
||||
* 第三方通知微信,打开硬件排行榜
|
||||
*/
|
||||
@interface OpenRankListReq : BaseReq
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - OpenRanklistResp
|
||||
/*! @brief 微信终端向第三方程序返回的OpenRankListReq处理结果。
|
||||
*
|
||||
* 第三方程序向微信终端发送OpenRankListReq后,微信发送回来的处理结果,该结果用OpenRankListResp表示。
|
||||
*/
|
||||
@interface OpenRankListResp : BaseResp
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - JumpToBizProfileReq
|
||||
/* ! @brief 第三方通知微信,打开指定微信号profile页面
|
||||
*
|
||||
* 第三方通知微信,打开指定微信号profile页面
|
||||
*/
|
||||
@interface JumpToBizProfileReq : BaseReq
|
||||
/** 跳转到该公众号的profile
|
||||
* @attention 长度不能超过512字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* username;
|
||||
/** 如果用户加了该公众号为好友,extMsg会上传到服务器
|
||||
* @attention 长度不能超过1024字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString* extMsg;
|
||||
/**
|
||||
* 跳转的公众号类型
|
||||
* @see WXBizProfileType
|
||||
*/
|
||||
@property (nonatomic, assign) int profileType;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - JumpToBizWebviewReq
|
||||
/* ! @brief 第三方通知微信,打开指定usrname的profile网页版
|
||||
*
|
||||
*/
|
||||
@interface JumpToBizWebviewReq : BaseReq
|
||||
/** 跳转的网页类型,目前只支持广告页
|
||||
* @see WXMPWebviewType
|
||||
*/
|
||||
@property(nonatomic, assign) int webType;
|
||||
/** 跳转到该公众号的profile网页版
|
||||
* @attention 长度不能超过512字节
|
||||
*/
|
||||
@property(nonatomic, retain) NSString* tousrname;
|
||||
/** 如果用户加了该公众号为好友,extMsg会上传到服务器
|
||||
* @attention 长度不能超过1024字节
|
||||
*/
|
||||
@property(nonatomic, retain) NSString* extMsg;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXCardItem
|
||||
|
||||
@interface WXCardItem : NSObject
|
||||
/** 卡id
|
||||
* @attention 长度不能超过1024字节
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* cardId;
|
||||
/** ext信息
|
||||
* @attention 长度不能超过2024字节
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* extMsg;
|
||||
/**
|
||||
* @attention 卡的状态,req不需要填。resp:0为未添加,1为已添加。
|
||||
*/
|
||||
@property (nonatomic,assign) UInt32 cardState;
|
||||
/**
|
||||
* @attention req不需要填,chooseCard返回的。
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* encryptCode;
|
||||
/**
|
||||
* @attention req不需要填,chooseCard返回的。
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* appID;
|
||||
@end;
|
||||
|
||||
#pragma mark - WXInvoiceItem
|
||||
|
||||
@interface WXInvoiceItem : NSObject
|
||||
/** 卡id
|
||||
* @attention 长度不能超过1024字节
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* cardId;
|
||||
/** ext信息
|
||||
* @attention 长度不能超过2024字节
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* extMsg;
|
||||
/**
|
||||
* @attention 卡的状态,req不需要填。resp:0为未添加,1为已添加。
|
||||
*/
|
||||
@property (nonatomic,assign) UInt32 cardState;
|
||||
/**
|
||||
* @attention req不需要填,chooseCard返回的。
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* encryptCode;
|
||||
/**
|
||||
* @attention req不需要填,chooseCard返回的。
|
||||
*/
|
||||
@property (nonatomic,retain) NSString* appID;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - AddCardToWXCardPackageReq
|
||||
/* ! @brief 请求添加卡券至微信卡包
|
||||
*
|
||||
*/
|
||||
|
||||
@interface AddCardToWXCardPackageReq : BaseReq
|
||||
/** 卡列表
|
||||
* @attention 个数不能超过40个 类型WXCardItem
|
||||
*/
|
||||
@property (nonatomic,retain) NSArray* cardAry;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - AddCardToWXCardPackageResp
|
||||
/** ! @brief 微信返回第三方添加卡券结果
|
||||
*
|
||||
*/
|
||||
|
||||
@interface AddCardToWXCardPackageResp : BaseResp
|
||||
/** 卡列表
|
||||
* @attention 个数不能超过40个 类型WXCardItem
|
||||
*/
|
||||
@property (nonatomic,retain) NSArray* cardAry;
|
||||
@end
|
||||
|
||||
#pragma mark - WXChooseCardReq
|
||||
/* ! @brief 请求从微信选取卡券
|
||||
*
|
||||
*/
|
||||
|
||||
@interface WXChooseCardReq : BaseReq
|
||||
@property(nonatomic, strong) NSString *appID;
|
||||
@property(nonatomic, assign) UInt32 shopID;
|
||||
@property(nonatomic, assign) UInt32 canMultiSelect;
|
||||
@property(nonatomic, strong) NSString *cardType;
|
||||
@property(nonatomic, strong) NSString *cardTpID;
|
||||
@property(nonatomic, strong) NSString *signType;
|
||||
@property(nonatomic, strong) NSString *cardSign;
|
||||
@property(nonatomic, assign) UInt32 timeStamp;
|
||||
@property(nonatomic, strong) NSString *nonceStr;
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - WXChooseCardResp
|
||||
/** ! @brief 微信返回第三方请求选择卡券结果
|
||||
*
|
||||
*/
|
||||
|
||||
@interface WXChooseCardResp : BaseResp
|
||||
@property (nonatomic,retain) NSArray* cardAry;
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - WXChooseInvoiceReq
|
||||
/* ! @brief 请求从微信选取发票
|
||||
*
|
||||
*/
|
||||
@interface WXChooseInvoiceReq : BaseReq
|
||||
@property (nonatomic, strong) NSString *appID;
|
||||
@property (nonatomic, assign) UInt32 shopID;
|
||||
@property (nonatomic, strong) NSString *signType;
|
||||
@property (nonatomic, strong) NSString *cardSign;
|
||||
@property (nonatomic, assign) UInt32 timeStamp;
|
||||
@property (nonatomic, strong) NSString *nonceStr;
|
||||
@end
|
||||
|
||||
#pragma mark - WXChooseInvoiceResp
|
||||
/** ! @brief 微信返回第三方请求选择发票结果
|
||||
*
|
||||
*/
|
||||
@interface WXChooseInvoiceResp : BaseResp
|
||||
@property (nonatomic, strong) NSArray* cardAry;
|
||||
@end
|
||||
|
||||
#pragma mark - WXSubscriptionReq
|
||||
@interface WXSubscribeMsgReq : BaseReq
|
||||
@property (nonatomic, assign) UInt32 scene;
|
||||
@property (nonatomic, strong) NSString * templateId;
|
||||
@property (nonatomic, strong) NSString * reserved;
|
||||
@end
|
||||
|
||||
#pragma mark - WXSubscriptionReq
|
||||
@interface WXSubscribeMsgResp : BaseResp
|
||||
|
||||
@property (nonatomic, strong) NSString *templateId;
|
||||
@property (nonatomic, assign) UInt32 scene;
|
||||
@property (nonatomic, strong) NSString *action;
|
||||
@property (nonatomic, strong) NSString * reserved;
|
||||
@property (nonatomic, strong) NSString * openId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXinvoiceAuthInsertReq
|
||||
@interface WXInvoiceAuthInsertReq : BaseReq
|
||||
|
||||
@property (nonatomic, strong) NSString *urlString;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXinvoiceAuthInsertResp
|
||||
|
||||
@interface WXInvoiceAuthInsertResp : BaseResp
|
||||
|
||||
@property (nonatomic, strong) NSString * wxOrderId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXNontaxPayReq
|
||||
@interface WXNontaxPayReq:BaseReq
|
||||
|
||||
@property (nonatomic, strong) NSString *urlString;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXNontaxPayResp
|
||||
@interface WXNontaxPayResp : BaseResp
|
||||
|
||||
@property (nonatomic, strong) NSString *wxOrderId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXPayInsuranceReq
|
||||
@interface WXPayInsuranceReq : BaseReq
|
||||
|
||||
@property (nonatomic, strong) NSString *urlString;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXPayInsuranceResp
|
||||
@interface WXPayInsuranceResp : BaseResp
|
||||
|
||||
@property (nonatomic, strong) NSString *wxOrderId;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXMediaMessage
|
||||
|
||||
|
||||
#pragma mark - WXMediaMessage
|
||||
|
||||
/*! @brief 多媒体消息结构体
|
||||
*
|
||||
* 用于微信终端和第三方程序之间传递消息的多媒体消息内容
|
||||
*/
|
||||
@interface WXMediaMessage : NSObject
|
||||
|
||||
+(WXMediaMessage *) message;
|
||||
|
||||
/** 标题
|
||||
* @note 长度不能超过512字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *title;
|
||||
/** 描述内容
|
||||
* @note 长度不能超过1K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *description;
|
||||
/** 缩略图数据
|
||||
* @note 大小不能超过32K
|
||||
*/
|
||||
@property (nonatomic, retain) NSData *thumbData;
|
||||
/**
|
||||
* @note 长度不能超过64字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *mediaTagName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *messageExt;
|
||||
@property (nonatomic, retain) NSString *messageAction;
|
||||
/**
|
||||
* 多媒体数据对象,可以为WXImageObject,WXMusicObject,WXVideoObject,WXWebpageObject等。
|
||||
*/
|
||||
@property (nonatomic, retain) id mediaObject;
|
||||
|
||||
/*! @brief 设置消息缩略图的方法
|
||||
*
|
||||
* @param image 缩略图
|
||||
* @note 大小不能超过32K
|
||||
*/
|
||||
- (void) setThumbImage:(UIImage *)image;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXImageObject
|
||||
/*! @brief 多媒体消息中包含的图片数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的图片数据对象。
|
||||
* @note imageData成员不能为空
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXImageObject : NSObject
|
||||
/*! @brief 返回一个WXImageObject对象
|
||||
*
|
||||
* @note 返回的WXImageObject对象是自动释放的
|
||||
*/
|
||||
+(WXImageObject *) object;
|
||||
|
||||
/** 图片真实数据内容
|
||||
* @note 大小不能超过10M
|
||||
*/
|
||||
@property (nonatomic, retain) NSData *imageData;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - WXMusicObject
|
||||
/*! @brief 多媒体消息中包含的音乐数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的音乐数据对象。
|
||||
* @note musicUrl和musicLowBandUrl成员不能同时为空。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXMusicObject : NSObject
|
||||
/*! @brief 返回一个WXMusicObject对象
|
||||
*
|
||||
* @note 返回的WXMusicObject对象是自动释放的
|
||||
*/
|
||||
+(WXMusicObject *) object;
|
||||
|
||||
/** 音乐网页的url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *musicUrl;
|
||||
/** 音乐lowband网页的url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *musicLowBandUrl;
|
||||
/** 音乐数据url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *musicDataUrl;
|
||||
|
||||
/**音乐lowband数据url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *musicLowBandDataUrl;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXVideoObject
|
||||
/*! @brief 多媒体消息中包含的视频数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的视频数据对象。
|
||||
* @note videoUrl和videoLowBandUrl不能同时为空。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXVideoObject : NSObject
|
||||
/*! @brief 返回一个WXVideoObject对象
|
||||
*
|
||||
* @note 返回的WXVideoObject对象是自动释放的
|
||||
*/
|
||||
+(WXVideoObject *) object;
|
||||
|
||||
/** 视频网页的url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *videoUrl;
|
||||
/** 视频lowband网页的url地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *videoLowBandUrl;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXWebpageObject
|
||||
/*! @brief 多媒体消息中包含的网页数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的网页数据对象。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXWebpageObject : NSObject
|
||||
/*! @brief 返回一个WXWebpageObject对象
|
||||
*
|
||||
* @note 返回的WXWebpageObject对象是自动释放的
|
||||
*/
|
||||
+(WXWebpageObject *) object;
|
||||
|
||||
/** 网页的url地址
|
||||
* @note 不能为空且长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *webpageUrl;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXAppExtendObject
|
||||
/*! @brief 多媒体消息中包含的App扩展数据对象
|
||||
*
|
||||
* 第三方程序向微信终端发送包含WXAppExtendObject的多媒体消息,
|
||||
* 微信需要处理该消息时,会调用该第三方程序来处理多媒体消息内容。
|
||||
* @note url,extInfo和fileData不能同时为空
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXAppExtendObject : NSObject
|
||||
/*! @brief 返回一个WXAppExtendObject对象
|
||||
*
|
||||
* @note 返回的WXAppExtendObject对象是自动释放的
|
||||
*/
|
||||
+(WXAppExtendObject *) object;
|
||||
|
||||
/** 若第三方程序不存在,微信终端会打开该url所指的App下载地址
|
||||
* @note 长度不能超过10K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *url;
|
||||
/** 第三方程序自定义简单数据,微信终端会回传给第三方程序处理
|
||||
* @note 长度不能超过2K
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *extInfo;
|
||||
/** App文件数据,该数据发送给微信好友,微信好友需要点击后下载数据,微信终端会回传给第三方程序处理
|
||||
* @note 大小不能超过10M
|
||||
*/
|
||||
@property (nonatomic, retain) NSData *fileData;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXEmoticonObject
|
||||
/*! @brief 多媒体消息中包含的表情数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的表情数据对象。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXEmoticonObject : NSObject
|
||||
|
||||
/*! @brief 返回一个WXEmoticonObject对象
|
||||
*
|
||||
* @note 返回的WXEmoticonObject对象是自动释放的
|
||||
*/
|
||||
+(WXEmoticonObject *) object;
|
||||
|
||||
/** 表情真实数据内容
|
||||
* @note 大小不能超过10M
|
||||
*/
|
||||
@property (nonatomic, retain) NSData *emoticonData;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#pragma mark - WXFileObject
|
||||
/*! @brief 多媒体消息中包含的文件数据对象
|
||||
*
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXFileObject : NSObject
|
||||
|
||||
/*! @brief 返回一个WXFileObject对象
|
||||
*
|
||||
* @note 返回的WXFileObject对象是自动释放的
|
||||
*/
|
||||
+(WXFileObject *) object;
|
||||
|
||||
/** 文件后缀名
|
||||
* @note 长度不超过64字节
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *fileExtension;
|
||||
|
||||
/** 文件真实数据内容
|
||||
* @note 大小不能超过10M
|
||||
*/
|
||||
@property (nonatomic, retain) NSData *fileData;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - WXLocationObject
|
||||
/*! @brief 多媒体消息中包含的地理位置数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的地理位置数据对象。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXLocationObject : NSObject
|
||||
|
||||
/*! @brief 返回一个WXLocationObject对象
|
||||
*
|
||||
* @note 返回的WXLocationObject对象是自动释放的
|
||||
*/
|
||||
+(WXLocationObject *) object;
|
||||
|
||||
/** 地理位置信息
|
||||
* @note 经纬度
|
||||
*/
|
||||
@property (nonatomic, assign) double lng; //经度
|
||||
@property (nonatomic, assign) double lat; //纬度
|
||||
|
||||
@end
|
||||
|
||||
@interface WXMiniProgramObject : NSObject
|
||||
|
||||
/*! @brief WXMiniProgramObject对象
|
||||
*
|
||||
* @note 返回的WXMiniProgramObject对象是自动释放的
|
||||
*/
|
||||
+(WXMiniProgramObject *) object;
|
||||
|
||||
@property (nonatomic, strong) NSString *webpageUrl; //低版本网页链接
|
||||
|
||||
@property (nonatomic, strong) NSString *userName; //小程序username
|
||||
|
||||
@property (nonatomic, strong) NSString *path; //小程序页面的路径
|
||||
|
||||
@property (nonatomic, strong) NSData *hdImageData; // 小程序新版本的预览图 128k
|
||||
|
||||
@property (nonatomic, assign) BOOL withShareTicket; //是否使用带 shareTicket 的转发
|
||||
|
||||
@property (nonatomic, assign) WXMiniProgramType miniProgramType; // 分享小程序的版本(正式,开发,体验)
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXLaunchMiniProgramReq
|
||||
|
||||
/*! @brief WXLaunchMiniProgramReq对象, 可实现通过sdk拉起微信小程序
|
||||
*
|
||||
* @note 返回的WXLaunchMiniProgramReq对象是自动释放的
|
||||
*/
|
||||
@interface WXLaunchMiniProgramReq : BaseReq
|
||||
|
||||
+(WXLaunchMiniProgramReq *) object;
|
||||
|
||||
@property (nonatomic, strong) NSString *userName; //拉起的小程序的username
|
||||
@property (nonatomic, strong) NSString *path; //拉起小程序页面的路径,不填默认拉起小程序首页
|
||||
@property (nonatomic, assign) WXMiniProgramType miniProgramType; //拉起小程序的类型
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - WXLaunchMiniProgramResp
|
||||
/*! @brief 微信终端向第三方程序返回的WXLaunchMiniProgramReq处理结果。
|
||||
*
|
||||
* 第三方程序向微信终端发送WXLaunchMiniProgramReq后,微信发送回来的处理结果,该结果用WXLaunchMiniProgramResp表示。
|
||||
*/
|
||||
@interface WXLaunchMiniProgramResp : BaseResp
|
||||
|
||||
@property (nonatomic, retain) NSString *extMsg;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark - WXTextObject
|
||||
/*! @brief 多媒体消息中包含的文本数据对象
|
||||
*
|
||||
* 微信终端和第三方程序之间传递消息中包含的文本数据对象。
|
||||
* @see WXMediaMessage
|
||||
*/
|
||||
@interface WXTextObject : NSObject
|
||||
|
||||
/*! @brief 返回一个WXTextObject对象
|
||||
*
|
||||
* @note 返回的WXTextObject对象是自动释放的
|
||||
*/
|
||||
+(WXTextObject *) object;
|
||||
|
||||
/** 地理位置信息
|
||||
* @note 文本内容
|
||||
*/
|
||||
@property (nonatomic, retain) NSString *contentText;
|
||||
|
||||
@end
|
||||
64
ios/Wechat/WechatAuthSDK.h
Normal file
64
ios/Wechat/WechatAuthSDK.h
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// WechatAuthSDK.h
|
||||
// WechatAuthSDK
|
||||
//
|
||||
// Created by 李凯 on 13-11-29.
|
||||
// Copyright (c) 2013年 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
enum AuthErrCode {
|
||||
WechatAuth_Err_Ok = 0, //Auth成功
|
||||
WechatAuth_Err_NormalErr = -1, //普通错误
|
||||
WechatAuth_Err_NetworkErr = -2, //网络错误
|
||||
WechatAuth_Err_GetQrcodeFailed = -3, //获取二维码失败
|
||||
WechatAuth_Err_Cancel = -4, //用户取消授权
|
||||
WechatAuth_Err_Timeout = -5, //超时
|
||||
};
|
||||
|
||||
@protocol WechatAuthAPIDelegate<NSObject>
|
||||
@optional
|
||||
|
||||
- (void)onAuthGotQrcode:(UIImage *)image; //得到二维码
|
||||
- (void)onQrcodeScanned; //二维码被扫描
|
||||
- (void)onAuthFinish:(int)errCode AuthCode:(NSString *)authCode; //成功登录
|
||||
|
||||
@end
|
||||
|
||||
@interface WechatAuthSDK : NSObject{
|
||||
NSString *_sdkVersion;
|
||||
__weak id<WechatAuthAPIDelegate> _delegate;
|
||||
}
|
||||
|
||||
@property(nonatomic, weak) id<WechatAuthAPIDelegate> delegate;
|
||||
@property(nonatomic, readonly) NSString *sdkVersion; //authSDK版本号
|
||||
|
||||
/*! @brief 发送登录请求,等待WechatAuthAPIDelegate回调
|
||||
*
|
||||
* @param appId 微信开发者ID
|
||||
* @param nonceStr 一个随机的尽量不重复的字符串,用来使得每次的signature不同
|
||||
* @param timeStamp 时间戳
|
||||
* @param scope 应用授权作用域,拥有多个作用域用逗号(,)分隔
|
||||
* @param signature 签名
|
||||
* @param schemeData 会在扫码后拼在scheme后
|
||||
* @return 成功返回YES,失败返回NO
|
||||
注:该实现只保证同时只有一个Auth在运行,Auth未完成或未Stop再次调用Auth接口时会返回NO。
|
||||
*/
|
||||
|
||||
- (BOOL)Auth:(NSString *)appId
|
||||
nonceStr:(NSString *)nonceStr
|
||||
timeStamp:(NSString*)timeStamp
|
||||
scope:(NSString *)scope
|
||||
signature:(NSString *)signature
|
||||
schemeData:(NSString *)schemeData;
|
||||
|
||||
|
||||
/*! @brief 暂停登录请求
|
||||
*
|
||||
* @return 成功返回YES,失败返回NO。
|
||||
*/
|
||||
- (BOOL)StopAuth;
|
||||
|
||||
@end
|
||||
BIN
ios/Wechat/libWeChatSDK.a
Normal file
BIN
ios/Wechat/libWeChatSDK.a
Normal file
Binary file not shown.
20
package.json
Normal file
20
package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
{
|
||||
"name": "react-native-wechat",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"react-native"
|
||||
],
|
||||
"author": "",
|
||||
"license": "",
|
||||
"peerDependencies": {
|
||||
"react-native": "^0.41.2",
|
||||
"react-native-windows": "0.41.0-rc.1"
|
||||
|
||||
}
|
||||
}
|
||||
83
src/const.js
Normal file
83
src/const.js
Normal file
@@ -0,0 +1,83 @@
|
||||
const WXScopes = {
|
||||
Base: 'snsapi_base', // 获取用户基本信息
|
||||
UserInfo: 'snsapi_userinfo', // 获取用户个人信息
|
||||
}
|
||||
|
||||
const WXScenes = {
|
||||
Session: 0, // 聊天界面
|
||||
Timeline: 1, // 朋友圈
|
||||
Favorite: 2, // 收藏
|
||||
}
|
||||
|
||||
const WXMiniProgramTypes = {
|
||||
Release: 0, // 正式版
|
||||
Test: 1, // 开发版
|
||||
Preview: 2, // 体验版
|
||||
}
|
||||
|
||||
const WXErrCode = {
|
||||
Success: 0, // 成功
|
||||
AppActiveSuccess: 1, // 应用唤起返回无法判断成功失败**非微信提供错误类型**
|
||||
Common: -1, // 普通错误类型
|
||||
UserCancel: -2, // 用户点击取消并返回
|
||||
SentFail: -3, // 发送失败
|
||||
AuthDeny: -4, // 授权失败
|
||||
Unsupport: -5, // 微信不支持
|
||||
}
|
||||
|
||||
const UserErrs = {
|
||||
// 微信错误并附带错误提示
|
||||
Success: {
|
||||
errCode: 0,
|
||||
errMsg: '',
|
||||
},
|
||||
Common: {
|
||||
errCode: -1,
|
||||
errMsg: '微信普通错误',
|
||||
},
|
||||
UserCancel: {
|
||||
errCode: -2,
|
||||
errMsg: '用户取消并返回',
|
||||
},
|
||||
SentFail: {
|
||||
errCode: -3,
|
||||
errMsg: '微信响应发送失败',
|
||||
},
|
||||
AuthDeny: {
|
||||
errCode: -4,
|
||||
errMsg: '微信响应授权失败',
|
||||
},
|
||||
Unsupport: {
|
||||
errCode: -5,
|
||||
errMsg: '微信不支持',
|
||||
},
|
||||
// 其它可能会产生的错误
|
||||
AppActiveSuccess: {
|
||||
errCode: 1,
|
||||
errMsg: '应用唤起返回无法判断成功失败',
|
||||
},
|
||||
Uninstall: {
|
||||
errCode: -6,
|
||||
errMsg: '当前设备未安装微信',
|
||||
},
|
||||
ApiUnregiste: {
|
||||
errCode: -7,
|
||||
errMsg: '微信Api未注册',
|
||||
},
|
||||
RequestSentFail: {
|
||||
errCode: -8,
|
||||
errMsg: '向微信发送请求失败',
|
||||
},
|
||||
Unknow: {
|
||||
errCode: -9,
|
||||
errMsg: '未知错误',
|
||||
},
|
||||
}
|
||||
|
||||
export {
|
||||
WXScopes,
|
||||
WXScenes,
|
||||
WXMiniProgramTypes,
|
||||
WXErrCode,
|
||||
UserErrs,
|
||||
}
|
||||
189
src/index.js
Normal file
189
src/index.js
Normal file
@@ -0,0 +1,189 @@
|
||||
import { NativeModules, NativeEventEmitter, AppState } from 'react-native'
|
||||
import { getWXScope, getWXScene, getWXMiniProgramType } from './util'
|
||||
import { WXErrCode, UserErrs } from './const'
|
||||
|
||||
const { RNWechat } = NativeModules
|
||||
|
||||
// wechat event emitter
|
||||
const rnWechatEmitter = new NativeEventEmitter(RNWechat)
|
||||
const rnWechatAddEventListener = listenEventType => {
|
||||
return new Promise(resolve => {
|
||||
let subscription = null
|
||||
// 微信返回事件处理
|
||||
const handleWechatEvent = ({ eventType, ...otherParams }) => {
|
||||
if (listenEventType !== eventType) return
|
||||
clearSubscribe()
|
||||
resolve(otherParams)
|
||||
}
|
||||
// 切换形式回到前台,拿不到微信的响应结果
|
||||
const handleAppStateChange = nextAppState => {
|
||||
if (nextAppState !== 'active') return
|
||||
clearSubscribe()
|
||||
resolve(UserErrs.AppActiveSuccess)
|
||||
}
|
||||
// 清理事件监听
|
||||
const clearSubscribe = () => {
|
||||
subscription.remove()
|
||||
AppState.removeEventListener('change', handleAppStateChange)
|
||||
}
|
||||
|
||||
subscription = rnWechatEmitter.addListener('RNWechatEvent', handleWechatEvent)
|
||||
AppState.addEventListener('change', handleAppStateChange)
|
||||
})
|
||||
}
|
||||
|
||||
// wechat response handler
|
||||
const handleWechatResponse = response => {
|
||||
const { errCode } = response
|
||||
if (errCode === WXErrCode.Success) {
|
||||
return response
|
||||
} else if (errCode === WXErrCode.AppActiveSuccess) {
|
||||
return response
|
||||
} else if (errCode === WXErrCode.Common) {
|
||||
throw UserErrs.Common
|
||||
} else if (errCode === WXErrCode.UserCancel) {
|
||||
throw UserErrs.UserCancel
|
||||
} else if (errCode === WXErrCode.SentFail) {
|
||||
throw UserErrs.SentFail
|
||||
} else if (errCode === WXErrCode.AuthDeny) {
|
||||
throw UserErrs.AuthDeny
|
||||
} else if (errCode === WXErrCode.Unsupport) {
|
||||
throw UserErrs.Unsupport
|
||||
} else {
|
||||
throw UserErrs.Unknow
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断微信是否可用
|
||||
* @return {Promise}
|
||||
*/
|
||||
let checkWechatEnable = async () => {
|
||||
let isWXAppInstalled = await RNWechat.isWXAppInstalled()
|
||||
if (isWXAppInstalled === 'false') {
|
||||
throw UserErrs.Uninstall
|
||||
}
|
||||
let isWXApiRegisteSuccess = await RNWechat.isWXApiRegisteSuccess()
|
||||
if (isWXApiRegisteSuccess === 'false') {
|
||||
throw UserErrs.ApiUnregiste
|
||||
}
|
||||
checkWechatEnable = () => true
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送授权请求
|
||||
* @param {String} appId appId
|
||||
* @param {String} state 用于验证微信返回信息
|
||||
* @param {String} [scope='userinfo'] 授权类型
|
||||
* @return {Promise}
|
||||
*/
|
||||
const sendAuthRequestScope = async ({
|
||||
appId,
|
||||
state,
|
||||
scope = 'userinfo',
|
||||
}) => {
|
||||
await checkWechatEnable()
|
||||
const mScope = getWXScope(scope)
|
||||
const sendRes = await RNWechat.sendAuthRequestScope(mScope, state, appId)
|
||||
if (sendRes === 'false') {
|
||||
throw UserErrs.RequestSentFail
|
||||
}
|
||||
const response = await rnWechatAddEventListener('SendAuthResp')
|
||||
return handleWechatResponse(response)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送文字
|
||||
* @param {String} text 文字
|
||||
* @param {String} [scene='session' }] 场景
|
||||
* @return {Promise}
|
||||
*/
|
||||
const sendText = async ({
|
||||
text,
|
||||
scene = 'session',
|
||||
}) => {
|
||||
await checkWechatEnable()
|
||||
const mScene = getWXScene(scene)
|
||||
const sendRes = await RNWechat.sendText(text, mScene)
|
||||
if (sendRes === 'false') {
|
||||
throw UserErrs.RequestSentFail
|
||||
}
|
||||
const response = await rnWechatAddEventListener('SendMessageToWXResp')
|
||||
return handleWechatResponse(response)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送链接
|
||||
* @param {String} url 点击后跳转的 url
|
||||
* @param {String} title 标题
|
||||
* @param {String} desc 描述
|
||||
* @param {String} thumb 缩略图
|
||||
* @param {String} [scene='session'] 场景
|
||||
* @return {Promise}
|
||||
*/
|
||||
const sendLinkURL = async ({
|
||||
url,
|
||||
title,
|
||||
desc,
|
||||
thumb,
|
||||
scene = 'session',
|
||||
}) => {
|
||||
await checkWechatEnable()
|
||||
const mScene = getWXScene(scene)
|
||||
const sendRes = await RNWechat.sendLinkURL(url, title, desc, thumb, mScene)
|
||||
if (sendRes === 'false') {
|
||||
throw UserErrs.RequestSentFail
|
||||
}
|
||||
const response = await rnWechatAddEventListener('SendMessageToWXResp')
|
||||
return handleWechatResponse(response)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送小程序或 url
|
||||
* @param {String} originId 小程序原始 id
|
||||
* @param {String} miniPgPath 小程序页面路径
|
||||
* @param {String} title 标题
|
||||
* @param {String} desc 描述
|
||||
* @param {String} hdImage 小程序缩略图
|
||||
* @param {String} url 旧版本替代用 url
|
||||
* @param {String} thumb 旧版本替代缩略图
|
||||
* @param {String} [type='release'] 小程序发布类型
|
||||
* @return {Promise}
|
||||
*/
|
||||
const sendMiniProgramWebpageUrl = async ({
|
||||
originId,
|
||||
miniPgPath,
|
||||
title,
|
||||
desc,
|
||||
hdImage,
|
||||
url,
|
||||
thumb,
|
||||
type = 'release',
|
||||
}) => {
|
||||
await checkWechatEnable()
|
||||
const mType = getWXMiniProgramType(type)
|
||||
const sendRes = await RNWechat.sendMiniProgramWebpageUrl(
|
||||
url,
|
||||
originId,
|
||||
miniPgPath,
|
||||
title,
|
||||
desc,
|
||||
thumb,
|
||||
hdImage,
|
||||
mType,
|
||||
)
|
||||
if (sendRes === 'false') {
|
||||
throw UserErrs.RequestSentFail
|
||||
}
|
||||
const response = await rnWechatAddEventListener('SendMessageToWXResp')
|
||||
return handleWechatResponse(response)
|
||||
}
|
||||
|
||||
export default {
|
||||
sendAuthRequestScope,
|
||||
sendText,
|
||||
sendLinkURL,
|
||||
sendMiniProgramWebpageUrl,
|
||||
}
|
||||
61
src/util.js
Normal file
61
src/util.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { WXScopes, WXScenes, WXMiniProgramTypes } from './const'
|
||||
|
||||
/**
|
||||
* 获取场景
|
||||
*/
|
||||
const getWXScene = scene => {
|
||||
switch (scene) {
|
||||
case 'session':
|
||||
return WXScenes.Session
|
||||
break
|
||||
case 'timeline':
|
||||
return WXScenes.Timeline
|
||||
break
|
||||
case 'favorite':
|
||||
return WXScenes.Favorite
|
||||
break
|
||||
default:
|
||||
return WXScenes.Session
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权类型
|
||||
*/
|
||||
const getWXScope = scope => {
|
||||
switch (scope) {
|
||||
case 'base':
|
||||
return WXScopes.Base
|
||||
break
|
||||
case 'userinfo':
|
||||
return WXScopes.UserInfo
|
||||
break
|
||||
default:
|
||||
return WXScopes.Base
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序类型
|
||||
*/
|
||||
const getWXMiniProgramType = type => {
|
||||
switch (type) {
|
||||
case 'release':
|
||||
return WXMiniProgramTypes.Release
|
||||
break
|
||||
case 'test':
|
||||
return WXMiniProgramTypes.Test
|
||||
break
|
||||
case 'preview':
|
||||
return WXMiniProgramTypes.Preview
|
||||
break
|
||||
default:
|
||||
return WXMiniProgramTypes.Release
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
getWXScope,
|
||||
getWXScene,
|
||||
getWXMiniProgramType,
|
||||
}
|
||||
Reference in New Issue
Block a user