Using Sinch with Xamarin - xamarin

I'm targetting iOS and Android platforms for a messaging application.
I want to use voice and messaging features of the sdk.
Are there any bindings available for sinch sdk for xamarin?

Sinch has a C# wrapper for sending SMS via their REST interface. It is available via a Nuget (Sinch.SMS) and/or you can grab the code on Github; https://github.com/sinch/Sinch.SMS
i.e. (from their hello world example):
To send an SMS use:
var client = new Sinch.SMS.Client("yourkey", "yoursecret");
var messageid = await client.SendSMS("+46722223355", "hello from sinch");
To check a status of an SMS use:
var client = new Sinch.SMS.Client("yourkey", "yoursecret");
var result = await client.CheckStatus(messageid);
As far as a complete SDK bindings for their Android/iOS SDKs, I do not know of one personally.
I 'just' would import them into XStudio and convert their sample call apps and give it a try. Should not take very long to see if the auto-wrappers work. Otherwise you would have manually correct/write the C# bindings to their 'native' lib

Here are some Xamarin binding libraries available on nuget. They are by a Vietnamese Software Development company called NAXAM. I believe these are all open source, and published on their github here: https://github.com/NAXAM
https://www.nuget.org/packages/Naxam.SinchVoice.Droid/
https://www.nuget.org/packages/Naxam.SinchVoice.iOS/3.11.0-pre1
https://www.nuget.org/packages/Naxam.SinchVerification.Droid/
https://www.nuget.org/packages/Naxam.SinchVerification.iOS/2.0.4-pre1

Related

Connecting to Event Hub

In my code below I am attempting to create a producer client that i can use to send events to a Event Hub. I am getting a System.PlatformNotSupportedException: 'The WebSocket protocol is not supported on this platform. error Any guidance on how i can resolve this would be much appreciated. FYI my platform is Windows 7, although this program is intended to run on a windows 2008 server or later.
var producerOptions = new EventHubProducerClientOptions
{
ConnectionOptions = new EventHubConnectionOptions
{
TransportType = EventHubsTransportType.AmqpWebSockets,
},
RetryOptions = new EventHubsRetryOptions
{
MaximumRetries = 5,
TryTimeout = TimeSpan.FromMinutes(1)
}
};
var producer = new EventHubProducerClient(connectionString, eventHubName, producerOptions);
//here is where the error occurs. which is inside a try - catch block
var eventBatch = await producer.CreateBatchAsync();
......
The Event Hubs client library relies on the underlying framework for its transport communication. In this case, it sounds as if you're using the full .NET Framework on Windows 7, where web sockets is not supported.
So long as your aren't using a UWP application, changing the target framework to .NET Core and using the netstandard2.0 target from the client library may work. (see: this PR)
More detail can be found in the accepted answer for this question, which also contains some advice for third party packages that may work as a polyfill.

Push Notification to specific devices on xamarin forms android/ios

I have successfully set up push notification using firebase and linked it up Azure notification hub using this guide from the Microsoft docs:
https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm
However I am now trying to push notification to specific devices using tags. There isn't currently a xamarin c# document. I have done some research around the area and found people solving what seems to be the same problem using dependency injection (which feels a little complex?). I have also found these two questions/answers:
How to push notification to specific users in Xamarin.Forms Android?
https://forums.xamarin.com/discussion/85935/how-to-push-notification-to-specific-users-in-xamarin-forms-android
Both of which point to the method "OnRegistered" which i don't seem to have? i've had another look through the documentation I followed to set up notifications in the first place and I seem to have followed it correctly?
I have the following code for android:
private void SendRegistrationToServer(string token)
{
// Register with Notification Hubs
hub = new NotificationHub(ApplicationConstants.NotificationHubName,
ApplicationConstants.ListenConnectionString, this);
var tags = new List<string>() { };
var regID = hub.Register(token, tags.ToArray()).RegistrationId;
}
I can obviously set the tags manually there, however how do i 'call' this Method again if the tags need to be changed?
So bottom line, my question is how do i set up push notification to specific devices on xamarin.forms android/ios?
Thanks.

xamarin android project access PCL function

I created a Cross Platform Xamarin Forms app. In the Portable Class I have a WebView that loads a web page from a URL.
From my Android project, I would like to be able to change the WebView URL.
What is the best way to do this ? I am kind of new to this, so any help to point me in the right direction would be great.
Thank you
I had a similar scenario in which I wanted to read the received SMS in Android project and send the message to PCL project.
For that I used Xamarin's MessagingCenter:
In Android's activity, upon receiving the SMS, I used the following code to send the SMS message body back to PCL:
MessagingCenter.Send<RegisterSecondPage, string>
(new RegisterSecondPage(), "OtpReceived", code);
And in one of my PCL pages I received it back like this:
MessagingCenter.Subscribe<RegisterSecondPage, string>
(new RegisterSecondPage(), "OtpReceived", async (s, code) =>
{
ActivationCode = code;
});
I believe you can use similar scenario as well.

How can i use internal database from scratch

How can i using internal database for example (sqlite) for offline app in nativescript without using any plugin.
i'm searched every were how i can installed or used sqlite or other internal database for nativescript but i didn't have any answer.
Just like you would do with any code that you need to access the native APIs
e.g. (JavaScript) Android example
var query = "select sqlite_version() AS sqlite_version";
var db = android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(":memory:", null);
var cursor = db.rawQuery(query, null);
var sqliteVersion = "";
if (cursor.moveToNext()) {
sqliteVersion = cursor.getString(0);
console.log(sqliteVersion);
}
The API references for SQLite in Android here and that said you can now follow a basic Android database tutorial and implement it step by step in your NativeScript application using JavaScript or TypeScript
Still, the plugin could provide all that wrapped in a ready-to-go functionality so unless you are lacking something it will be easier to use the nativescript-sqlite and avoid writing native code for Android and then for iOS.

How to make use of Text to Speech in Windows Phone App

I am a newbie to Windows Phone App Development. I am building a Windows Phone App where I want the App to greet the logged in user and also greet when logging out.
You can make use of the built-in Text-To-Speech engine. It doesn't even need to connect to internet.
You can try something like this:
var text2speech = new SpeechSynthesizer();
await text2speech.SpeakTextAsync("Welcome to Text To Speech");
Hope it works. You can easily include this in a function and call it when the MainPage loads.
See more at: http://www.programfreaks.com/windowsphone/texttospeech.aspx

Resources