fbsdkmessagedialog callback for iOS - facebook-ios-sdk

I'm new to IOS programming, I'm trying to send message to Facebook friends using the below
[FBSDKMessageDialog showWithContent:content delegate:(id)self];
I have added callback as below:
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NSLog(#"complete");
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
NSLog(#"Cancelled")
}
But the sharer method is not called when I send a message in FB messenger rather the sharerDidCancel is called. The sharerDidCancel method is called when user cancels or send a message, how can I differentiate send vs cancel?

Facebook has a confirmed bug concerning this, however the addressed bug there is that it always calls sharer:didCompleteWithResults instead of sharerDidCancel.
Their next release contain a fix for this (v45) and hopefully this fixes our bug too (I'm having the same problem).

Related

Initiate message from bot in dialogflow

I want to get the welcome message from bot first in dialogflow. I am not sure how to do this. Any ideas on how to do this.
I tried reading about events in dialogflow as Default welcome intent uses "Welcome" event. But not able to find any solution.
As I opened up my bot framework, it should pop up "Hi, I am a virtual assistant. How can I help you?"
I am not sure of which bot technology you are using, but if your front end is in html/js, you may call a function like this:
Define it something like:
function myFunction(){
''here you may pass a parameter to your bot to display a pre-defined message. I am not going in details here, as I am not sure about the framework you are using.''
}
The onload (in body) will call myFunction(), everytime the page is refreshed.
P.s - I will update this answer once I get more details from your end. Since I am new here, please excuse in case of any issues.

Can you check if a Phone Number is a verified caller ID through the twilio-client?

I need a Twilio expert to answer a question for me if they can. I have an application I'm developing in which we want a user to be able to enter a phone number and call someone with a selected phone number as the caller ID. Trick is that caller ID must be in our account Verified Caller IDs list. Now I have found several examples and tutorials about how to do this using the Twilio SDK, however we're using that on our back-end where all our tokens are stored and Twilio-Client on the front-end. Does anyone know of a way to verify a callerID using the Twilio-Client device on the front-end? Big thanks in advance.
Twilio developer evangelist here.
The Twilio Client JS SDK is mostly concerned with placing calls using WebRTC. It does not include features for calling the regular API, including the verified caller id list.
You could do a couple of things here.
Either, before you place the call, make an ajax request to your own server and make a check there against your verified caller IDs.
Or, when the call is placed and Twilio sends the webhook to your TwiML application, check the caller ID is valid at that point. If it isn't, respond to the webhook with a message using <Say> to tell the caller they are trying to call from an invalid caller ID and then <Hangup/>. If it is valid, then place the outbound call leg with <Dial>.
Let me know if that helps at all.
I found two ways to verify a callerID.
get a list of numbers from your account and loop through them as follows:
https://www.twilio.com/docs/voice/api/outgoing-caller-ids?code-sample=code-list-an-accounts-outgoing-caller-ids&code-language=PHP&code-sdk-version=6.x
$outgoingCallerIds = $twilio->outgoingCallerIds
->read([], 20);
foreach ($outgoingCallerIds as $record) {
print $record->sid.",".$record->phoneNumber.",".$record->friendlyName;
}
attempt the validate the number and watch for an error
https://www.twilio.com/docs/voice/api/outgoing-caller-ids#add-an-outgoing-caller-id
try{
$validation_request = $twilio->validationRequests
->create("+1".$cell, // phoneNumber
["friendlyName" => $name]
);
} catch (Throwable $e){
$pos=(strpos($e,"Phone number is already verified") );
if (is_numeric($pos) ) { do something }
}

Progressive Web Application receiving data to trigger notification

Hello i'm newbie and im hardly to understand this notification in service-worker, and because my knowledge isn't good yet then probably i will unable to explain my problem clearly.
so here's the code :
// triggered everytime, when a push notification is received.
self.addEventListener('push', function(event) {
console.info('Event: Push');
var title = 'New commit on Github Repo: RIL';
var body = {
'body': 'Click to see the latest commit',
'tag': 'pwa',
'icon': './images/48x48.png'
};
event.waitUntil(
self.registration.showNotification(title, body)
);
});
this is the code that trigger to POP the notification, what I do not understand is where the argument to accept/ receive the data ?
I've been searched a lot: https://auth0.com/blog/introduction-to-progressive-web-apps-push-notifications-part-3/ ,
https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web
there's some new data JSON or from git-server or push api, but I still hardly to understand where's to accept the data.
sorry if you still do not understand what's my problem.
Here to make it simple what I want :
Let's say i make a button, and everytime i click the button it will value as 'True' and I want that 'True' value to pass into argument and trigger the push of notication in service-worker.
2nd questions: am I able to trigger notification with header or text in html ? since we can manipulate the text with DOM ?
am I able to trigger notification without GCM, or API cause I just want a simple notification in serivce-worker like above without passing much data.
If you give more advice or maybe notification without service-worker but real time , I am surely happy to read it but I hope Im able to understand.
There are basically two concepts involved that work well together but can be used independently. The first is the visible UI shown to a user that tells them information or prompts them for an action. The second is sending an event from a server to the browser without requiring the user to currently be active on the site. For full details I recommend reading Google's Web Push docs.
Before either of those scenarios you have to request permission from the user. Once permission is granted you can just create a notification. No server or service worker required.
If you want to send events from a server you will need a service worker and you will need to get a subscription for the user. Once you have a subscription you would send it to a server for when you want to send an event to that specific browser instance.
Once you receive a push event from a server you display the UI the same as in the first scenario except you have to do it from the service worker.

How to detect when bot was added to conversation and other events?

I am testing a bot that I am building using the Bot Framework. The emulator for local testing that Microsoft created has several events that can be provided to the bot to solicit a response.
I looked at the GitHub samples provided for Node.js here, but I can not find any example that responds to the different events within the Bot Framework Emulator.
The states are:
Bot Added to Conversation
Bot Removed from Conversation
User Added to Conversation
User Removed from Conversation
End of Conversation
Ping
Delete User Data
The API also does not make it clear how to achieve any of these actions.
Does anyone have any insight on where I should be looking for a example, or the API entries that I should be using?
In response to one of the answers, I did try code -
.onDefault(function (session) { console.log(session.message.type); }
But it only ever display "message" if a message was sent by the user.
The incoming message.type field will have "BotAddedToConversation" etc.
For the Node SDK, the botConnectorBot is able to trigger custom listeners on events using the on() handler.
Example
var builder = require('botbuilder');
var bot = new builder.BotConnectorBot({ appId: 'APPID', appSecret: 'APPSECRET' });
bot.on('DeleteUserData', function(message) {
// Handle Deleting User Data
});
More information can be found here.
You are also able to configure some standard messages using the configure() method.
Example
bot.configure({
userWelcomeMessage: "Hello... Welcome to the group.",
goodbyeMessage: "Goodbye..."
});
More information on what can be configured through options is located here.
Concerns
This is not part of the question, as the question was to identify how to listen to these events. But as a general concern, the event listener does not return a session object. It is unclear how to act once you handle the event.

Azure Notifications to WP and iOS

My app uses an Azure Notification Hub to send messages to both Windows Phone and iOS devices. The problem is that they work if one is called, but it doesn't work if both are called.
For example, If I send a message to an iOS device from my iOS emulator, the following code works fine and the notification appears.
var toast = PrepareMpnsToastPayload("myapp", notificationText);
var appleToast = PrepareAppleToastPayload("myapp", notificationText);
//await NotificationHelper.Instance.Hub.SendMpnsNativeNotificationAsync(toast, userTag);
await NotificationHelper.Instance.Hub.SendAppleNativeNotificationAsync(appleToast, userTag);
However, if I uncomment the SendMpns..() line, the notification never gets to the apple device. When stepping through this code with remote debugging, the call to SendMpns..() doesn't seem to return. I step over it and it just resumes.. and the breakpoint on the SendApple..() call below it never gets hit.
This works the same with the Windows Phone Mpns line (works fine without the apple call).
How am I supposed to send an alert to a user when I don't know what device they are on? I just want to send the notification to all types. Any pointers would be greatly appreciated.
EDIT: The below answers of removing await() did work. However as I now have authenticated notification hub I need to capture the return value of the call so I can see if I need to get another auth token if it has expired!
If posted code runs as trivial console application then we should wait for tasks to be completed. Easiest way to do so is removing await and calling Wait() against Task object returned by xAsync() methods:
NotificationHelper.Instance.Hub.SendMpnsNativeNotificationAsync(toast, userTag).Wait();
NotificationHelper.Instance.Hub.SendAppleNativeNotificationAsync(appleToast, userTag).Wait();

Resources