[DEPRECATED!]
$ npm install react-native-sinch-rtc --save
- Download Sinch SDK for Android and move sinch .aar library file to your android folder in a libs folder
- In module gradle file:
Add to repositories
flatDir { dirs './libs' }
maven { url 'https://maven.google.com' }
To dependencies
compile 'com.google.firebase:firebase-messaging:11.8.0'
And apply plugin
apply plugin: 'com.google.gms.google-services'
- To project gradle file:
classpath 'com.google.gms:google-services:3.1.1'
- Add Sinch dependency to your Podfile inside ios folder
pod 'SinchRTC'
- Inside ios folder run
pod install
- Add Header Search Path
$(SRCROOT)/../node_modules/react-native-sinch-rtc/ios/Classes
$ react-native link react-native-sinch-rtc
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-sinch-rtc
and addRNSinchRtc.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNSinchRtc.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.RNSinchRtcPackage;
to the imports at the top of the file - Add
new RNSinchRtcPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-sinch-rtc' project(':react-native-sinch-rtc').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sinch-rtc/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-sinch-rtc')
Add Keys, Secret and Environment to your Manifest
<service android:name="com.bluecall.sinch.SinchService">
<meta-data android:name="messages_handler" android:value="com.bluecallapp.utils.sinch.MessagesHandler" />
<meta-data
android:name="SINCH_APP_KEY"
android:value="@string/SINCH_APP_KEY" />
<meta-data
android:name="SINCH_APP_SECRET"
android:value="@string/SINCH_APP_SECRET" />
<meta-data
android:name="SINCH_ENVIRONMENT"
android:value="@string/SINCH_ENVIRONMENT" />
</service>
Add Keys, Secret and Environment to the Module initialization
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[RNSinchRtc initialize:@{@"isMessagingEnabled":@YES,
@"appKey":@"",
@"appSecret":@"",
@"host":@"",
@"environment":@"dev" // For development, empty or other value for production
@""
}];
}
import { NativeModules } from 'react-native';
NativeModules.RNSinchRtc.login('username');
NativeModules.RNSinchRtc.setDisplayName('username');
NativeModules.RNSinchRtc.call('user_id', callId => {
console.log(callId);
}
NativeModules.RNSinchRtc.hangup();
const emitter = Platform.OS === 'android' ? DeviceEventEmitter : new NativeEventEmitter(NativeModules.RNSinchRtc);
emitter.addListener('callEndedWithReason', event => {
console.log(event.duration);
console.log(event.reason);
});
emitter.addListener('callDidEstablish', event => {});
emitter.addListener('callDidProgress', event => {});
The developer is reponsible of how the Notifications are shown for the incoming Instant Messages. To handle the notifications the class will need to implement MessagesHandlerable
, this class will implement:
onIncomingMessage
at this point you have the option to present a local notificationonSendingMessage
at this point the user is sending a message and the developer has the option to do any required treatment needed for the sent message.