mirror of
https://github.com/zhigang1992/agora-react-native-rtm.git
synced 2026-05-30 20:13:33 +08:00
chore. upgrade agora-rtm native sdk to 1.0.0
This commit is contained in:
5
CHANGELOG
Normal file
5
CHANGELOG
Normal file
@@ -0,0 +1,5 @@
|
||||
## CHANGELOG
|
||||
|
||||
## release 1.0.0-alpha.1
|
||||
+ getSdkVersion
|
||||
+ setSdkLog
|
||||
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
||||
s.source = { :git => package["repository"]["url"], :tag => "#{s.version}" }
|
||||
s.source_files = 'ios/src/**/*.{h,m}'
|
||||
|
||||
s.dependency 'AgoraRtm_iOS', '0.9.3'
|
||||
s.dependency 'AgoraRtm_iOS', '1.0.0'
|
||||
s.dependency 'React'
|
||||
s.ios.deployment_target = '8.0'
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ dependencies {
|
||||
def androidSupportVersion = rootProject.hasProperty("androidSupportVersion") ? rootProject.androidSupportVersion : DEFAULT_ANDROID_SUPPORT_VERSION
|
||||
// from internet
|
||||
implementation "com.android.support:appcompat-v7:$androidSupportVersion"
|
||||
implementation 'io.agora.rtm:rtm-sdk:0.9.3'
|
||||
implementation 'io.agora.rtm:rtm-sdk:1.0.0'
|
||||
// from node_modules
|
||||
implementation "com.facebook.react:react-native:+"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.agora.agora_rtm;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
@@ -34,6 +35,7 @@ import io.agora.rtm.RtmClient;
|
||||
import io.agora.rtm.RtmClientListener;
|
||||
import io.agora.rtm.RtmMessage;
|
||||
import io.agora.rtm.SendMessageOptions;
|
||||
import io.agora.rtm.internal.RtmSdkContext;
|
||||
|
||||
public class AgoraRTMModule extends ReactContextBaseJavaModule
|
||||
implements RtmClientListener, RtmCallEventListener, RtmChannelListener {
|
||||
@@ -107,6 +109,27 @@ public class AgoraRTMModule extends ReactContextBaseJavaModule
|
||||
rtmClient = null;
|
||||
}
|
||||
|
||||
// get sdk version
|
||||
@ReactMethod
|
||||
public void getSdkVersion(Callback callback) {
|
||||
callback.invoke(RtmClient.getSdkVersion());
|
||||
}
|
||||
|
||||
// set sdk log
|
||||
@ReactMethod
|
||||
public void setSdkLog(final String path, final Integer level, final Integer size,
|
||||
final Promise promise) {
|
||||
Integer setpath = rtmClient.setLogFile(path);
|
||||
Integer setlevel = rtmClient.setLogFilter(level);
|
||||
Integer setsize = rtmClient.setLogFileSize(size);
|
||||
WritableMap data = Arguments.createMap();
|
||||
data.putBoolean("path", setpath == 0);
|
||||
data.putBoolean("size", setsize == 0);
|
||||
data.putBoolean("level", setlevel == 0);
|
||||
promise.resolve(data);
|
||||
}
|
||||
|
||||
|
||||
// login
|
||||
@ReactMethod
|
||||
public void login(final ReadableMap params, final Promise promise) {
|
||||
@@ -433,13 +456,14 @@ public class AgoraRTMModule extends ReactContextBaseJavaModule
|
||||
public void sendLocalInvitation (ReadableMap params, final Promise promise) {
|
||||
final String calleeId = params.getString("uid");
|
||||
final LocalInvitation localInvitation = rtmCallManager.createLocalInvitation(calleeId);
|
||||
final String channelId = params.getString("channelId");
|
||||
String content = null;
|
||||
if(params.hasKey("content")) {
|
||||
content = params.getString("content");
|
||||
String content = params.getString("content");
|
||||
localInvitation.setContent(content);
|
||||
}
|
||||
localInvitation.setChannelId(channelId);
|
||||
if(params.hasKey("channelId")) {
|
||||
String channelId = params.getString("channelId");
|
||||
localInvitation.setChannelId(channelId);
|
||||
}
|
||||
rtmCallManager.sendLocalInvitation(localInvitation, new ResultCallback<Void> () {
|
||||
@Override
|
||||
public void onSuccess(Void aVoid) {
|
||||
@@ -460,12 +484,15 @@ public class AgoraRTMModule extends ReactContextBaseJavaModule
|
||||
final String calleeId = params.getString("uid");
|
||||
if (null != localInvitations.get(calleeId)) {
|
||||
final LocalInvitation localInvitation = localInvitations.get(calleeId);
|
||||
String channelId = params.getString("channelId");
|
||||
if (params.hasKey("content")) {
|
||||
String content = params.getString("content");
|
||||
localInvitation.setContent(content);
|
||||
}
|
||||
localInvitation.setChannelId(channelId);
|
||||
if (params.hasKey("channelId")) {
|
||||
String channelId = params.getString("channelId");
|
||||
localInvitation.setChannelId(channelId);
|
||||
}
|
||||
|
||||
rtmCallManager.cancelLocalInvitation(localInvitation, new ResultCallback<Void> () {
|
||||
@Override
|
||||
public void onSuccess(Void aVoid) {
|
||||
|
||||
@@ -120,6 +120,30 @@ RCT_EXPORT_METHOD(logout:(RCTPromiseResolveBlock)resolve
|
||||
}];
|
||||
}
|
||||
|
||||
// get sdk version
|
||||
RCT_EXPORT_METHOD(getSdkVersion:(RCTResponseSenderBlock)callback) {
|
||||
callback(@[[AgoraRtmKit getSDKVersion]]);
|
||||
}
|
||||
|
||||
// set sdk log
|
||||
RCT_EXPORT_METHOD(setSdkLog:(NSString *)path
|
||||
level:(NSInteger)level
|
||||
size:(NSInteger)size
|
||||
resolve:(RCTPromiseResolveBlock)resolve
|
||||
reject:(RCTPromiseRejectBlock)reject) {
|
||||
int fileSize = (int) size;
|
||||
int setpath = [[AgoraRtmKit new] setLogFile:path];
|
||||
int setsize = [[AgoraRtmKit new] setLogFileSize:fileSize];
|
||||
int setlevel = [[AgoraRtmKit new] setLogFilters:level];
|
||||
|
||||
resolve(@{
|
||||
@"path": @(setpath == 0),
|
||||
@"size": @(setsize == 0),
|
||||
@"level": @(setlevel == 0)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// renewToken
|
||||
RCT_EXPORT_METHOD(renewToken:(NSString*)token
|
||||
resolve:(RCTPromiseResolveBlock)resolve
|
||||
@@ -352,7 +376,9 @@ RCT_EXPORT_METHOD(sendLocalInvitation:(NSDictionary *)params
|
||||
if ([params objectForKey:@"content"]) {
|
||||
localInvitation.content = params[@"content"];
|
||||
}
|
||||
localInvitation.channelId = params[@"channelId"];
|
||||
if ([params objectForKey:@"channelId"]) {
|
||||
localInvitation.channelId = params[@"channelId"];
|
||||
}
|
||||
[_rtmCallManager sendLocalInvitation:localInvitation completion:^(AgoraRtmInvitationApiCallErrorCode errorCode) {
|
||||
if (0 != (int)errorCode) {
|
||||
reject(@(-1).stringValue, @(errorCode).stringValue, nil);
|
||||
@@ -373,7 +399,9 @@ RCT_EXPORT_METHOD(cancelLocalInvitation:(NSDictionary *)params
|
||||
if ([params objectForKey:@"content"]) {
|
||||
localInvitation.content = params[@"content"];
|
||||
}
|
||||
localInvitation.channelId = params[@"channelId"];
|
||||
if ([params objectForKey:@"channelId"]) {
|
||||
localInvitation.channelId = params[@"channelId"];
|
||||
}
|
||||
[_rtmCallManager cancelLocalInvitation:localInvitation completion:^(AgoraRtmInvitationApiCallErrorCode errorCode) {
|
||||
if (0 != (int)errorCode) {
|
||||
reject(@(-1).stringValue, @(errorCode).stringValue, nil);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "agora-react-native-rtm",
|
||||
"version": "0.9.3-beta.2",
|
||||
"version": "1.0.0-alpha.1",
|
||||
"description": "React Native around the Agora RTM SDKs for Android and iOS agora",
|
||||
"summary": "agora native rtm sdk for react-native",
|
||||
"main": "lib/RtmEngine.js",
|
||||
|
||||
@@ -25,7 +25,7 @@ const { AgoraRTM } = NativeModules;
|
||||
export default class RtmEngine {
|
||||
|
||||
// sdk version
|
||||
private static readonly version: string = '0.9.3-beta.1';
|
||||
private static readonly version: string = '1.0.0-alpha.1';
|
||||
|
||||
// internal event identifiy for RtmEngine
|
||||
private static readonly AG_RTMCHANNEL = "ag_rtm_";
|
||||
@@ -38,6 +38,26 @@ export default class RtmEngine {
|
||||
this.events = new NativeEventEmitter(AgoraRTM);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the version of rtm sdk
|
||||
* @param callback (version) => {} required
|
||||
*/
|
||||
getSdkVersion (callback: void): void {
|
||||
AgoraRTM.getSdkVersion(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* set sdk log file
|
||||
* @param path string: specified the generated log path
|
||||
* @param level number: sdk log level (0: "OFF", 0x0f: "INFO", 0x0e: "WARN", 0x0c: "ERROR", 0x08: "CRITICAL")
|
||||
* @param size number: file size in kbytes
|
||||
* Note File size settings of less than 512 KB or greater than 10 MB will not take effect.
|
||||
* @return Promise<any> This method will return {path: boolean, level: boolean, size: boolean}
|
||||
*/
|
||||
setSdkLog (path: string, level: number, size: number): Promise<any> {
|
||||
return AgoraRTM.setSdkLog(path, level, size)
|
||||
}
|
||||
|
||||
/**
|
||||
* supports platform: ios, android
|
||||
* @events {@link RtmEngineEvents}
|
||||
|
||||
4
src/types.d.ts
vendored
4
src/types.d.ts
vendored
@@ -33,8 +33,8 @@ export interface UserAttribute {
|
||||
|
||||
export interface LocalInvitationProps {
|
||||
uid: string
|
||||
content?: string
|
||||
channelId: string
|
||||
content?: string // recommnd used with rtm communication
|
||||
channelId?: string // recommnd used with signal service communication
|
||||
}
|
||||
|
||||
export interface RemoteInvitationProps {
|
||||
|
||||
Reference in New Issue
Block a user