Xamarin.Android Send Whatsapp Message - xamarin.android

I use this code to send a Message to WhatsApp:
string phoneNumberWithCountryCode = "+20>>>>>>>>";
string message = "Test Program \n Test Program \n Test";;
StartActivity(new Intent(Intent.ActionView,
Android.Net.Uri.Parse(
"https://api.whatsapp.com/send?phone=" + phoneNumberWithCountryCode + "&text=" + message)));
It seems ok, but the message isn't send to a receiver. Instead, it is being sent to the WhatsApp textbox and I need to press Go or Enter to send the Message.
How do I write 'Press go' or 'Enter' in my code to send it directly? I need Send Key like C#.

Related

While adding Alphanumeric Sender ID I always got error in php

I had purchased a USA number and I am trying to send a programable message to Hong Kong. While I send with a simple Twilio number it works fine and message recieved.
But when I try to add alphanumeric Sender ID it always show error message. The error message is: Message: [HTTP 400] Unable to create record: The 'From' number infoSMS is not a valid phone number, shortcode, or alphanumeric sender ID.
What I had tried is
public function send_sms(){
$msg_to = $_REQUEST['msg_to'];
$msg_body = $_REQUEST['msg_body'];
$twilio = new Client("ACba7f3a6866a23aed021056d3ceaexxxx", "4d7e47e92a8351b7365ed1e3e83dxxxx");
$message = $twilio->messages->create(
$msg_to, // to
[
"body" => $msg_body,
"from" => "infoSMS";
]
);
if($message->sid) {
$this->session->set_flashdata('ok_message', '- SMS successfully sent!');
redirect(AURL . 'Sms/sent_sms_list');
}else {
$this->session->set_flashdata('err_message', '- Error in sending sms please try again!');
redirect(SURL . 'Sms/create_sms');
}
}
I had read the documentation: https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id
What I am doing wrong? Thanks in advance.
Twilio developer evangelist here.
This was a bit hard to track down, but it turns out that there are a few generic alphanumeric sender IDs that may cause delivery failures. I tried to send an SMS using "infoSMS" as the sender ID and was unable to do so as well.
On some of our SMS guideline pages, there is this note about alphanumeric sender IDs:
Generic Alpha Sender IDs like InfoSMS, INFO, Verify, Notify etc should be avoided as they will result in SMS failures
I recommend you try using a different alphanumeric sender ID that more closely represents your business or service.

TComPort : How To Check Response from an AT Command after Send SMS

I'm using TComPort Component in Delphi to send Bulk SMS messages via GSM Modem. I just need to make sure that The Modem Reply "OK" before sending the next sms.
Here Is My Code :
with cds_kontak do
if not cds_kontak.Eof then
begin
sProgressBar1.Position := sProgressBar1.Position + 1;
ComPort1.WriteStr('at+cmgs="' + cds_kontak.FieldValues['NO_SELULER'] + '"'+#13);
ComPort1.WriteStr(mmo_sms.Text+#26);
cds_kontak.Next;
end
I would like to insert code to check the Modem Reply, if the Reply is "OK" then continue to next list.

How do I get the user message that a Slack Botkit hears?

Using Botkit, how can I get the message from the user that triggered what a Botkit hears? For example, a user says "Hello, how are you" and the bot hears "hello" as the keyword. I do I get the entire "Hello, how are you"?
In case anyone else was wondering, you use message.text to access the message.

Worklight: Push Notification message length & formatting - limitations

I am facing below issues when sending Push notifications through Worklight.
Push Message length is very much limited - around 65 characters
payload message when received on device has removed all spacing
like i sent "This is a test message" but on device it received as "Thisisatestmessage"
Now , what is the limited size of Push message in worklight specially , i know Apple says for 256 Bytes. But what Worklight allows?
and why payload is removing spaces. Even i am sending message from a back-end java service
My Push Adapter:
function generalNotification(userId, msgTitle, MsgContents, org, logo){
var userSubscription = WL.Server.getUserNotificationSubscription('aahadPushAdapter.GeneralPushSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
WL.Logger.debug("Sending Push >> userId:: " + userId + ", Message:: " + MsgContents);
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "Read",
alert: msgTitle,
payload: {
msg : MsgContents,o:org,l:logo
}
});
return { result: "Notification sent to user :: " + userId };
}
my back-end Java code:
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
String parm = "['" + userID + "','"+ msgTitle + "','"+ msgContents+ "','"+org + "','"+logo +"']";
ProcedureQName pushMethod = new ProcedureQName("aahadPushAdapter","transNotification");
InvocationResult results = service.invokeProcedure(pushMethod, parm);
jsonObj = results.toJSON();
msg = "Push Sent successfully to " + userID + " " + (String)jsonObj.get("");
Please check this code and suggest , if something is missing here?
thanks
Does the stripping of spaces also happen in the Push Notifications sample application provided in the IBM Worklight Getting Started training material? Because for me, it doesn't.
If it happens only in your application, need to understand how you're processing the message.
As I have mentioned to you in a comment elsewhere, Worklight does not place any restrictions - each PNS (APNS, MSPN, GCM) has its own limitation.
The 256 bytes are not only for the message part of the payload, but for the entirety of the payload, so it could be that for the message part what is left is only 65 characters, but again, this is not in Worklight's control.
I haven't done this yet myself, but you can start stripping the payload and see when it fails, that would be your minimum payload from Worklight's perspective.
The message is not meant to be long in principle.
Another way to maybe increase what you can pass in the message (in the remaining size of the payload) is to use an alias so that less information is passed, thus more space remains for the message.
The stripping of spaces in APNS payload appears to be a defect. I seen the same behavior in my application and was able to reproduce it in the getting started materials. As a workaround I put "_" in the payload as a placeholder for spaces and then removed them in the worklight client.

how to share a link via sms in blackberry

I am building an application where I need the option to share via email and SMS.
I have done the share via Email, where when the user selects the image, the url is passed as the content of the email. But while sharing via SMS, I can't do something like setContent as I did for email and fetch the url in the SMS directly, instead of user typing the address manually.
I am using Message class in email and MessageConnection class for SMS, as shown in the blackberry community example.
The Message object you receive when calling MessageConnection.newMessage(TEXT_MESSAGE) is actually a TextMessage object (or a BinaryMessage object with BINARY_MESSAGE).
If you cast the received object to the proper class (TextMessage or BinaryMessage), you should be able to use its setPayloadText(String data) (or setPayloadData(byte[] data) for a BinaryMessage) to enter a value in the message before sending it.
Your code should look like this:
Message msg = myMessageConnection.newMessage(TEXT_MESSAGE, /* address */);
TextMessage txtMsg = (TextMessage)msg;
txtMsg.setPayloadText(/* Text to send */);
myMessageConnection.send(msg);
When you send an email, you can set the body of it and send it to the user from the Email native application. You cant do taht for SMSs. I worked on that issue and for BB Torch I was able to set the text of the SMS message but for other devices that was impossible. I always obtain an empty text message!!
So y suggestion to you is using the following code wich will send the SMS to a number without the interference of the user
MessageConnection conn = (MessageConnection) Connector.open("sms://" + userNumber);
TextMessage txtmessage = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
txtmessage.setPayloadText(text);
conn.send(txtmessage);

Resources