Facebook plugin for phonegap ios application - share on the wall - ios

I am trying to share from my phonegap ios application. I use this code to post to my facebook wall
var facebookConnectPluginPostToTheWall = function () {
var options =
{
method: "feed",
name: "Shared via my cool app",
message: "This is a post shared from my app. I have earned 300xps."
};
facebookConnectPlugin.showDialog(options,
function (response) {
alert(JSON.stringify(response))
});
};
And it shares the post to the facebook, but I can't make it work with these preset values for message, title etc. It just shares the text I enter in the popup shown after calling this function. I hope someone can help with this.

The feed dialog does not accept any prefilled messsage - but prefilling is not allowed anyway, the message always must be 100% user generated.
If you want to post without a dialog, you have to authorize the user with publish_actions and use the feed API: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/feed
But again, prefilling the message is not allowed. Read the platform policy for more information: https://developers.facebook.com/policy/

Related

Sending sms from iOS app using Plivo API swift

How do I use plivo SMS API in my iOS app using Swift. I read lot of documentation regarding this. I'm not sure how to implement it on swift.
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: 'Your AUTH_ID',
authToken: 'Your AUTH_TOKEN'
});
var params = {
'src': '1111111111', // Sender's phone number with country code
'dst' : '2222222222', // Receiver's phone Number with country code
'text' : "Hi, text from Plivo", // Your SMS Text Message - English
//'text' : "こんにちは、元気ですか?", // Your SMS Text Message - Japanese
//'text' : "Ce est texte généré aléatoirement", // Your SMS Text Message - French
'url' : "http://example.com/report/", // The URL to which with the status of the message is sent
'method' : "GET" // The method used to call the url
};
// Prints the complete response
p.send_message(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
console.log('Message UUID:\n', response['message_uuid']);
console.log('Api ID:\n', response['api_id']);
});
The above code is in Node.js, I want it to write in swift, and also I'm not sure how to integrate plivo into iOS app. I'm developing an app where it should send a sms to admin whenever user requests an order. So I just want the outgoing message from Plivo to admin. Any suggestions is really helpfull.
Plivo Sales Engineer here. Our recommendation is to host a server to which your iOS app would make a request to send the SMS. Then your server can use a Plivo helper library to make the API request which would send the SMS. This way your AuthID and AuthToken are stored on your server (to which only you have complete access) and you don't expose your Plivo credentials in your iOS app.
If you make a direct request of the Plivo API from your iOS app, then users potentially could find and misuse your credentials.
tl;dr - don't put your authentication credentials in places other people can read it.
So without a helper library you will have to just make use of their REST API. From their site, sending an SMS can be done by POSTing your information to
https://api.plivo.com/v1/Account/{auth_id}/Message/
As for the Swift part take a look at NSMutableURLRequest or if you need help with the networking request you can look at Alamofire
If you want to use Rest API you can do like this:
lazy var plivoRestAPI: PlivoRest = {
let rest = PlivoRest(authId: Constants.Credentials.Plivo.AuthId,
andAuthToken: Constants.Credentials.Plivo.AuthToken)!
rest.delegate = self
return rest
}()
let params = ["to": phoneNumberToCall,
"from": "1111111111",
"answer_url": "",
"answer_method": "GET"]
plivoRestAPI.callOutbound(params)

Facebook Open Graph Stories in iOS successfully creates an object but cannot post to fb timeline

I am trying to implement Open Graph Stories in iOS of facebook as shown in here: https://developers.facebook.com/docs/sharing/opengraph/ios#custom
I need to post it to facebook via custom interface, not with facebook share dialog.
So far, I can successfully create an open graph object per request, it does not return any error but does not post it to Facebook timeline neither. All I see in xcode is: postId: 113077439054125, completionGesture: post
I am not sure what goes wrong.
Here is my code snippet:
var photo = FBSDKSharePhoto(imageURL: imgUrl, userGenerated: false)
var properties : [NSObject : AnyObject] = [
"og:type" : "video.movie",
"og:title" : "TEST TITLE",
"og:image" : "https://www.facebook.com/images/fb_icon_325x325.png",
"fb:explicitly_shared" : true]
var object = FBSDKShareOpenGraphObject(properties: properties)
var shareApi = FBSDKShareAPI()
var action = FBSDKShareOpenGraphAction(type: "MYNAMESPACE:myAction", object: object, key: "movie")
var content = FBSDKShareOpenGraphContent()
content.action = action
content.previewPropertyName = "movie"
shareApi.delegate = self
shareApi.shareContent = content
shareApi.share()
I've been struggling with it for some time by now. Any help would be appreciated.
Thanks.
You should have solved it. If not, did you get the token for publish_actions permission?
This is how you can get it:
Go to Graph API Explorer.
Select your application.
Click "Get User Access Token".
Select "Extended Permissions" then "publish_actions".
Click "Get Access Token".
That's it.
You have to get your app approved by Facebook in order to gain publish_actions right? When you login to Facebook what are the different access permissions that it shows. Usually you will get a line in the Facebook permission page that says this app does not let you post to timeline or something like that.
What you can try is to create Test Users and use it to login. Test users get all the permissions that you ask for since they are separate from normal users. Note that these are not same as Testers which are still normal FB accounts.
Try using Test Users and once your app is ready to go live, send it to Facebook from the app dashboard and once approved by them you should be good to go live.

KIK Card - sending message directly

I'm building new KIK Card and i would like to create button which will send messages to 5 people selected from kik.pickUsers Is there any command that allow me to send messages directly, without pressing button "send"? This is my code:
cards.kik.pickUsers({
minResults: 5, // number >= 5
maxResults: 99 // number < 99
}, function (users) {
if (!users) {
return;
}
users.forEach(function (user) {
cards.kik.send(user.username, {
title: 'Message',
text: 'Text!!!'
});
});
});
Messages cannot be sent directly without user consent (via pressing the "send" button) - this is a tactic to avoid apps spamming content messages on behalf of the user.
Regarding sending to multiple people, as of this writing you can only send a message to a group if the conversation already exists in Kik.
Iterating over the array of users returned from the picker and trying to use kik.send() for each will only work for the first user in the array.
The Pop app on Kik has a good implementation to overcome this for inviting friends to use the app. This may or may not be relevant depending on what you are developing.

Trigger the native contacts ui in phonegap [ios]

I've been looking through the documentation for the Contacts API and there are ways to retrieve and save contacts to display them on your own UI.
But is there any way to trigger the native contacts to display your address book?
Something similar to the SMS plugin which pops up the native sms composer within the app.
Thanks
I was looking for the exact same thing and came across this http://fqnow.com/phonegap-contact-picker/. Here's the Javascript code, all you need to do is:
function contactChooser(){
var options = new ContactFindOptions();
options.fields = ["displayName", "name", "emails", "phoneNumbers"];
navigator.contacts.chooseContact( onSuccess, options);
}
function onSuccess(id, contact){
alert(id);
alert(contact);
}

Twitter Callback URL opens up after posting text on twitter in Blackberry?

I am providing google url as call back url in my application. But after posting the text to my page my application opens that Google page in foreground which is of-course its a bug in application.
I just need that after posting the text control returns to my application.
I am using the code from this link :
Twitter-is-Integrated-in-BlackBerry
If I don't provide the Call back URL, twitter demands for PIN NUMBER before login.
please suggest me for this problem.
Please use TwitterAPIMe as it is.It is Simple to Use No need for PIN based Authentication and Library will Automatically Redirect you after login from Twitter to your application. You have to change in some native code of API that...
Go To: com.twitterapime.xauth.ui.OAuthDialogWrapper Class
Go to method called trackUrl(String url)
Now Replace the Code:
if (url.startsWith(callbackUrl)&& oauthListener != null) { .... ... ..
}
With:
if (url.indexOf(callbackUrl)!=-1 && oauthListener != null) { .... ...
.. }
That's it. Simply get AccessToken inside onAurthorize method and access Twitter API. Most of the functionalities and methods are covered inside this api.

Resources