How to use FCMClient to send messages to both Android and iPhone - c#

Im using FCMClient in an MVC application to send alerts/messages to Android and iPhones.
I initialise https://github.com/tiagomtotti/firebaseNet/blob/master/src/FirebaseNet/Messaging/Message.cs and then send a message.....
var msg = new Message
{
To = token,
Data = someData
}
This sends alerts to an Android but not an iPhone. I looked at the documentation https://github.com/tiagomtotti/firebaseNet
and can see two classes AndroidNotifcation and IosNotification (https://github.com/tiagomtotti/firebaseNet/tree/master/src/FirebaseNet/Messaging)
I now noticed the Message class takes in an Interface for both notifications but how could setup the Message class to take in a notification but targets both Android and IoS?

Related

Group PWA notifications on Android

I'm using the WebPush c# assembly (v1.0.11) to send push notifications to my PWA.
My payload looks like this:
{
"notification":{
"title":"My Message",
"body":"Hello World, here is a message for you",
"data":{
"FromContactpersonId":"e3600a03-836e-4c01-42c7-08d879cb6c81"},
"badge":"assets/icons/badge72push.png"}
}
Now I want to group the notifications on android. If I set tag in the payload it will replace the last message, but I want them all to show, just stacked, like the e-mails in this example (compared to my own, which are not stacked):
I tried adding android_group but the messages do not get stacked at all.
How can I send them so they will be stacked on my android device?
Thanks, Sam

How to use BroadcastReceiver in Xamarin with C #?

I need to generate a notification when the app is in the background, but I'm not sure how to start Broadcastreceiver
There are two ways:
1. LocalBroadcastManager will send messages only to your application
Intent message = new Intent("com.xamarin.example.TEST");
// If desired, pass some values to the broadcast receiver.
intent.PutExtra("key", "value");
Android.Support.V4.Content.LocalBroadcastManager.GetInstance(this).SendBroadcast(message);
2. Context.SendBroadcast methods will send messages to the entire system
Intent message = new Intent("com.xamarin.example.TEST");
// If desired, pass some values to the broadcast receiver.
intent.PutExtra("key", "value");
context.SendBroadcast(intent);
from Xamarin guide

How to Send SMS on Xamarin.Forms

I am developing Xamarin.Forms project, iOS, Android and Windows Phone.
My app ask the user to enter text Message and Phone number then on submit, I need to send SMS to the phone number.
I prefer to have a single implementation for all platforms.
You can use this open source plugin Xam.Plugins.Messaging
https://github.com/cjlotz/Xamarin.Plugins
This is the provided example (from https://github.com/cjlotz/Xamarin.Plugins/blob/master/Messaging/Details.md ) :
// Make Phone Call
var phoneDialer = CrossMessaging.Current.PhoneDialer;
if (phoneDialer.CanMakePhoneCall)
phoneDialer.MakePhoneCall("+272193343499");
// Send Sms
var smsMessenger = CrossMessaging.Current.SmsMessenger;
if (smsMessenger.CanSendSms)
smsMessenger.SendSms("+27213894839493", "Well hello there from Xam.Messaging.Plugin");
var emailMessenger = CrossMessaging.Current.EmailMessenger;
if (emailMessenger.CanSendEmail)
{
// Send simple e-mail to single receiver without attachments, bcc, cc etc.
emailMessenger.SendEmail("to.plugins#xamarin.com", "Xamarin Messaging Plugin", "Well hello there from Xam.Messaging.Plugin");
// Alternatively use EmailBuilder fluent interface to construct more complex e-mail with multiple recipients, bcc, attachments etc.
var email = new EmailMessageBuilder()
.To("to.plugins#xamarin.com")
.Cc("cc.plugins#xamarin.com")
.Bcc(new[] { "bcc1.plugins#xamarin.com", "bcc2.plugins#xamarin.com" })
.Subject("Xamarin Messaging Plugin")
.Body("Well hello there from Xam.Messaging.Plugin")
.Build();
emailMessenger.SendEmail(email);
}
Microsoft now has this feature in their new all-encompasing https://learn.microsoft.com/en-us/xamarin/essentials NuGet package.

Send simple text message to wechat user from server side

I have wechat app on Android, in Settings->MyAccount I set WeChat ID "my-wechat-unical-id".
In WebForms project I add WeChat.SDK 1.0.1.9
now I obtain ACCESS_TOKEN like this:
https://api.wechat.com/cgi-bin/token?grant_type=client_credential&appid=my_appid&secret=my_secret
How I can to send simple message to 'my-wechat-unical-id' if this person is not my follower, can I send to him some message or notification in wechat?

Sending SMS with delivery message

How can i write code for send SMS with delivery message in Windows Mobile? please guide me with C# or C++ code.
I want to use SmsSendMessage API in this code because this API have more features.
You could use SmsSendMessage to send the message and use SmsGetMessageStatus to get the status report of the sent SMS. This is all C++ code, but you can pinvoke it as well.
Microsoft.WindowsMobile.PocketOutlook Namespace
The Microsoft.WindowsMobile.PocketOutlook namespace provides classes that allow you to create and access PIM data items (Appointments, Tasks, and Contacts), and MAPI messaging items (e-mail and SMS messages), on mobile devices
SmsMessage Class in msdn
This sample shows how to send an SMS message to a mobile phone.
public void SmsMessageSend()
{
SmsMessage smsMessage = new SmsMessage();
//Set the message body and recipient.
smsMessage.Body = "Would you like to meet for lunch?";
smsMessage.To.Add(new Recipient("John Doe", "2065550199"));
smsMessage.RequestDeliveryReport = true;
//Send the SMS message.
smsMessage.Send();
return;
}

Categories