How to Detect incoming VOIP calls with Sinch provider when app is offline - sinch

I am using sinch for VOIP calls. I need to know how to detect incoming calls when my app is offline or the process is killed. It can be done through background service but cannot understand how to build such service and which method can be used.

You can check the device status whether it is active or inactive
- (void)client:(id<SINCallClientDelegate>)client didReceiveIncomingCall:(id<SINCall>)call {
if (call.details.applicationStateWhenReceived == UIApplicationStateActive) {
//perform segue
}
}

Basically when the app is offline, Sinch sends a push message that should be intercepted in GcmBroadcastReceiver and then you call GcmIntentService which initializes Sinch and connects you to the call. Of course you need to setSupportManagedPush(true) and setSupportPushNotifications(true) when initializing your SinchClient.
There's a sample project provided by Sinch to help you with all this.
Just go to Sinch website and download the ANDROID SDK 3.9.3 ZIP file. It has a samples folder that contains 5 projects.
Check the project sinch-rtc-sample-push, it has the GCM implementation along with a SinchService. You can use the same classes in your project.

Related

Call and online meeting bot - Peer to peer call is terminated automatically

I am trying to develop a simple bot that is supposed to answer incoming call made in personal chat with bot. The bot is employing application hosted media to play or get access to media streams. I am making use of classes and controllers that are implemented in Huebot sample project at Github. The bot is registered on MS Azure and i am using ngrok for local testing and debugging. While debugging after making the call, breakpoints are hit that are placed in 'CallsOnIncoming' or 'CallsOnUpdated' event handlers. So my bot configurations over Azure and in MS Teams seem to be correct. For setting up media platform, I have installed the wildcard SSL certificated issued by Let's Encrypt and CName records are created for corresponding tcp URLs exposed by ngrok. The environment is multi-tenant i.e. bot registration is done on another tenant, while bot is installed and tested in MS Teams on another tenant.
These are Media platform settings:
MediaPlatformInstanceSettings = new MediaPlatformInstanceSettings()
{
CertificateThumbprint = "0B687..................",
InstanceInternalPort = 8445,
InstancePublicPort = 15410,
InstancePublicIPAddress = new IPAddress(0x0),
ServiceFqdn = "4.mycustomdomain.com",
},
Here's the snapshot for ngrok:
The problem is, when call is made to the bot, after 5 to 10 seconds call is terminated automatically. Whereas he Call status should turn to 'Established' and the call shouldn't end until user does this.Please guide, what could be wrong.
The call is terminating because Teams can't connect to your media endpoint of the InstancePublicIPAddress / InstancePublicPort. It timesout (i believe in 15 seconds) and terminates the call when it can't get a media connection.
You need to put the IP address of 4.tcp.ngrok.io from your running ngrok settings above into it.
e.g.
InstancePublicIPAddress = Dns.GetHostEntry("4.tcp.ngrok.io").AddressList[0]
You may want to put error checking around the GetHostEntry call in production code.

Azure Notification Hub losing the subscribe when app is reinstalled

I have a problem with Azure Notification Hub.
When my app is started in first time, the notifications working correctly, but when did a rebuild the app by Visual Studio, the notifications stop working and the Android Services with IntentFilters do not are called.
For the notifications works again, I need to uninstall the App in Android and run by Visual Studio again.
Have someone some idea about that problem?
My worry is: if I send the app to GooglePlay, the notifications would continue working after a update?
If someone know how to call the service to get the new InstallationId, always that the app to be started I will know how I can resolve the problem.
Can someone help me?
I did follow that tutorial:
https://www.youtube.com/watch?v=le2lDY22xwM&t=3312s
if I send the app to GooglePlay, the notifications would continue working after a update?
There is no need to worry about that, referring to this document, when you use Azure Notification Hub, it's using Android GCM to send the push notificcation. You could see my answer about Android using Firebase Cloud Messaging not receiving message.
As the Official document said :
On initial startup of your app, the FCM SDK generates a registration token for the client app instance. If you want to target single devices or create device groups, you'll need to access this token.
Explanation about Token :
An ID issued by the GCM connection servers to the client app that allows it to receive messages.
When you did a rebuild the app by Visual Studio your token is changed, but it didn't trigger the OnTokenRefresh method, so at this time the Token in your application is invalid. That's why your application cannot receiving message.
For more information, you could refer to Sending Push Notifications from Azure Mobile Apps and Implement the Firebase Instance ID Service.
When your app get a update, it will trigger the OnTokenRefresh method automatically, so your application can still receive the message.

Sinch Managed Push not working for some mobile devices (Android)

mSinchClient = Sinch.getSinchClientBuilder().context(getApplicationContext()).userId(username)
.applicationKey(APP_KEY)
.applicationSecret(APP_SECRET)
.environmentHost(ENVIRONMENT).build();
mSinchClient.setSupportCalling(true);
mSinchClient.setSupportManagedPush(true);
mSinchClient.checkManifest();
//mSinchClient.startListeningOnActiveConnection();
mSinchClient.addSinchClientListener(new MySinchClientListener());
mSinchClient.getCallClient().addCallClientListener(new SinchCallClientListener();
The code is implemented to sense incoming calls using sinch, and it works well on some mobiles. But there are also devices where the incoming call is not sensed. The GCM receiver though receives the call when the app is ON, but the incoming call method is not called.
Please suggest how to tackle this issue. My device has android 4.4.4 version. Is it version dependent?

Android Watch/Phone MessageApi

I am working on an app for Android Watch that requires the mobile app to be on or in background. I tried using the MessageApi in order to communicate with the app on the phone, but even if the app is not on, i get a message back like it is on.
What would you suggest to check whether the phone app is running (doesnt matter whether it is foreground/background) before i enable the activity on the Android Watch?
Thanks for the help.
If you have registered a WearableListenerService in your mobile app, that will be invoked by the framework even if your app is not running (and will be invoked if your app is running, too). If, however, you are not using that service, then to receive messages or notification on changes in the wear network in your mobile app, you would need to register one or more callback listeners for the type of messages/data that you are interested in. In that case, that means if your app is not running, you will not be getting those callbacks on your mobile app. To use this, however, be sure to manage the lifecycle of your listeners in your mobile app according to your needs. For example, one can register for such listeners in onResume() of an activity and unregister in onPause(). The consequence of that is if your activity loses focus (but still alive), that activity will not receive the callback (even though as an instance it is still running). You may want to define an Application instance for your app and use that to listen for callbacks but, again, it depends on the exact nature of your needs and app.
You can search for nodes and parse them for needed result, or to check if you have a nearBy node
private Collection<String> getNodes() {
HashSet <String>results = new HashSet<String>();
NodeApi.GetConnectedNodesResult nodes =
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
for (Node node : nodes.getNodes()) {
results.add(node.getId());
}
return results;
}

Sinch APN shouldSendPushNotifications never called

I can´t make Apple Push Notifications work in development mode. The shouldSendPushNotifications method is never called on the source device when the target device is in background mode. I have uploaded my APN development certificate in the Sinch Dashboard and instant messaging works if both devices are in foreground mode. I have a valid device token which I´m using for my own Push Messages. Here is my code:
sinCli = Sinch.clientWithApplicationKey("XXXX", applicationSecret: "XXXX", environmentHost: "sandbox.sinch.com", userId: sinchUserId)
sinCli.delegate = self
sinCli.setSupportMessaging(true)
if let deviceToken = defaults.dataForKey(Globals.KEY_APN_DEVICE_TOKEN)
{
sinCli.setSupportPushNotifications(true)
sinCli.registerPushNotificationDeviceToken(deviceToken, type: SINPushTypeRemote, apsEnvironment: SINAPSEnvironment.Development)
sinCli.setPushNotificationDisplayName("MyApp")
}
sinCli.start()
sinCli.startListeningOnActiveConnection()
sinCli.messageClient().delegate = self
did I forget something?
I think I need to see your swift wrapper, but it almost looks like you are setting up the client for push (not managed), and then registring the token for managed push.
When using managed push (when you upload to cert to us) shouldSendPush is never called, because Sinch takes care of the pushing, you should just get a push. What you do need is to have a push delegate https://www.sinch.com/tutorials/ios-managed-push/

Resources