Facebook iOS SDK Pass parameter with app requests - ios

I would like to have my native iOS app send a request with a parameter to a Facebook user on iOS. If they accept, it will launch my native iOS app and pass it the parameter. Is this possible?
I am having marginal success using [facebook dialog:#"apprequests" andParams:dict andDelegate:self]. I am getting the bookmark counter to increment on Facebook iOS app, but I do not see the individual requests. If I tap the bookmark it launches my app but I do not see how I can get the "data" parameter I passed with the request, or even the request_id.
On desktop I see the individual messages under "Requests" section of "Apps and Games". If I accept a request, I can see it pass the request_id to my (simple echo) canvas URL. I read this can be used to fetch the associated data. But, this does not help me on iOS. My app only runs on iOS, so this canvas app will eventually just be a "this app only works on iOS," but it seemed to be necessary to get the requests to flow.
Neither of these are showing me Notifications, so maybe I am doing something basic wrong. Or, is there some other way to pass a message to a Facebook user, with a URL they could click (to launch and feed my app its parameter).
One other odd thing, I do not see how to get rid of the Requests. If I "X" them on the desktop client, it asks me if I want to stop receiving all requests from my app, and if I say no, it only hides them temporarily.

Leif, Hi - I'm the engineer at Facebook who wrote the tutorial you've referenced.
I've taken a look at the issue you've mentioned - this is in fact not a bug in the documentation and is by design.
The incoming url from a request on iOS looks something like this:
fb480369938658210://authorize?expires_in=3600&access_token=BAAG05NeN86IBAC31YWMWRHVrNCAYMy0Rv1OtqZCwdH8QDBUAt5KgZCsIbU0EOZAvMms2tZCANV9sZBWSkEzStDtt4i7YnYZA4bPgGx2XaI5s22iBMxIZAneZAv7ADi3Wi20ZD&target_url=http%3A%2F%2Fm.facebook.com%2Fapps%2Ffriendsmashsample%3Ffb_source%3Dnotification%26request_ids%3D364209433669109%252C379616028785376%252C494409170593789%252C489782271042929%252C328564930575784%26ref%3Dnotif%26app_request_type%3Duser_to_user
This is bundling together several requests, with multiple request ids into a single url.
To get the extra data coupled with this request, it is not required to have the user_id. Hitting graph.facebook.com/*request_id* is enough.
You can actually see this outlined in the documentation here: https://developers.facebook.com/docs/requests/#deleting under the 'Request ID Format' heading.
The code contained in the Friendsmash sample and on the tutorial works correctly - I verified it just now. So it should serve as a good guide to the OP's question.
Thanks!

I have been struggling with this too.
First, the FB iOS SDK requests tutorial is a good start.
However, there are also a few bugs that makes things not work as expected:
It seems that currently, a mobile web url has to be set up for the FB app in order for requestIds to be forwarded from the native FB app to your native app. See this bug report.
The tutorial mentioned above uses an erroneous graph path for the request object. I uses "request-id" where it should be "request-id"_"user-id". I have filed a documentation bug report on that issue.

Related

branch test app link weird behaviour for facebook/twitter deep linking - iOS

I am using branch for deep linking on facebook as well as twitter. Deep linking opens up my app successfully and I am also able to retrieve all the parameters correctly. But at one instance, it stopped working and said developers are working on it and after 2 days started working again after I submitted a ticket to Branch and without me changing anything. But this weird stopping and starting of link is not good for app users. Can someone from Branch help me know the possible cause for the same, as for the live app, this would create a problem?
The reason why you are experiencing this issue is that apps like Facebook, Twitter, Instagram and Snapchat prevent users from opening a third-party app via Universal Links. One way to mitigate this issue is to use forced redirections via URI Schemes on the in-app browser. You can enable forced redirections on Branch links by appending $uri_redirect_mode=2 as a query parameter.
eg:
https://example.app.link/j93str?$uri_redirect_mode=2
If you are still experiencing issues, please write to integrations#branch.io with a video recording of the link redirection behavior and one of our engineers would be able to help you with this.
Branch documentation includes two types of method calls - synchronous and asynchronous calls to method that generates url. If we are using asynchronous call, it would take time to give us the url so need to check for url first before posting it on social sharing and if we are using synchronous call, we get a short url which can be easily shared to social sites. This is what made a difference for me!!

IOS Deeplinking- Pass msg from email to your app

Existing user of the app will send email to other user.
Other user may have app installed or not installed on their device.
The email will contain some token. Now I want to pass that token to my app. I have read that by deep-linking, its possible. But how will I handle the case when other user have not installed my app yet in their IOS device.
Any help is appreciated.
What you're describing is called Deferred Deep Linking (Deep Linking refers to using a link to open your app, even directly to a specific piece of content, and Deferred means that it works even if the app isn't installed first).
Unfortunately there's no native way to accomplish this yet on either iOS or Android. URL schemes don't work, because they always fail if the app isn't installed. Apple's new Universal Links in iOS 9 get closer, but you'd still have to handle redirecting the user from your website to the App Store
A free service like Branch.io (full disclosure: they're so awesome I work with them) can handle all of this for you though. Here's the docs page covering exactly how to create email links like you described: https://docs.branch.io/pages/emails/email-partners-list/

Mobile Number Verification with Missed Call in iOS

I don't know this question is a good question or dumb question, but I research on SO from last 3 days, only this link I am able to see. And in this link I am not getting any solution for my Issue.
My question is How to verify my mobile number with a missed call. I got from some answer, have to use "Dial2Verify" API. But no one can said "How to use that API" in iOS mobile application through coding. I follow Dial2Verify site for more information, but its only for PHP developer.
My requirement is: I have a call button on my app screen, when I pressed that button, that method will call to Dial2Verify API, And give a missed call to Dial2Verify API and after register Dial2Verify will send that API key/ Mobile number to my App Server, Then App server will check the mobile number is registered or not, if register then it directly go to Home page off App otherwise stay on that Login page.
I would suggest use of mOTP API. (MOTP.in )
Again a service by dial2verify, but it is more suitable for app integration as it supports 200+ countries.
A clever alternative to SMS otp.
At the core it's a 2 step process.
1 sending mOTP : you would be required to call a remote URL from app ( which would send missed call otp to end user )
Step 2: you are required to call another URL from app to cross check otp entered by user.
There is a flow demo available on mOTP website.
Do share the code you build so others can be benefited.
You can probably use a service like https://checkmobi.com/ . Basically they have available 4 validations methods: SMS, IVR, Missed call (the one you need) and another one called CLI.
You can check how each method is working here: https://checkmobi.com/documentation.html#/overview
Also they have available a iOS and Android SDK for mobiles and quite good pricing model for startups.

iOS Conversion / installation Tracking

Objective: i want to fetch my custom parameter(referrer) from iTunes link upon installation of my application in device.
iTunes links look somethings like this:
https://itunes.apple.com/in/app/complete-gym-guide-lite/id550449574?mt=8
If i append my parameter say(&referrer=xyz)at the end and i open this url in ios safari browser then it will prompt to download the application.
Confusion: will app store send my parameter(referrer) to my application on launch so that i can fetch it in my application and use it.
In case of Android play store link look like this: http://play.google.com/store/apps/details?id=&referrer=guid%3D%guid%
As you can see referrer parameter at the end of url. Once app is installed in device then play store will send this parameter to app using INSTALL_REFERRER broadcast receiver. We can use this parameter.
What i tried OR Other people doing for conversion tracking: Other people are simply sending static data to their server at the first time opening of app and maintain a flag in NSDefault to make sure that app does not send same data again. I can also do the same as well as alternate ways suggested in below links but i want to do something with custom parameter.
I have already seen below links:
iOS - track which ad campaigns my installs are coming from
Tracking iOS installs from multiple marketing sources
Please help me out.
As #Aditya said, for now, Apple is not sending any referrer (or params) from iTunes to installation.
The only way you have it's to use a third party sdk to get your installations.
I have been working on a own sdk to get this but the way to get any info it's really hard and not really confident to use it. So endly we used some third party which are using many techniques to getting this (as fingerprint data, App2App methods, etc...)
I have tested appsflyer sdk and facebook sdk, they work as expected, use this or any else you prefer.
Hope this helps

How to share links via FB App when I am offline

I am developing an mobile app for iPhone. The app will primary used by people who are on holiday in a different country and will be offline most of the time, due to high costs for internet traffic.
However, the company for which I am developing the app wants to users to be able to use the "Facebook Share" functionality also when people are not connected to the internet.
It should work on a way that they click the SHARE link button in the app, but then get a message that they are offline and the link will get shared as soon as they are online again.
I am trying to figure out how to do this. Can I pass the link I want to share to the official FB App via fb:// protocol (or whatever) and the FB App handles the post/share as soon as it is online again?
Or do I have to do it on my own, put the links I want to share in a internal database and then post them to the wall when I am online again?
Or any other ways??
Any suggestions would be welcome, I would prefer a very quick solution and hope someone maybe has an idea how to do this. I was hoping I can pass the share-link to the official FB App and this one handles everything when it goes online again !?
Thanks for your ideas!
Your approach should be to make your link-sharing code automatically cache requests until they are sent. The app then doesn't need to concern itself with the details - it can just post the link and get a 'failed', 'success', or 'postponed' response from your API and notify the user accordingly.
Your link-sharing code can then internally check if it can currently post to FB and if not (either because the user is currently offline or perhaps the Facebook token is expired) it will store it for later. This class will then re-check periodically (for example when the app comes to the foreground or when the class is initialised the next time the app starts) for connectivity and then it will check if the token is still valid and perform FB login if required. Once it has a valid token it can then iterate through the pending requests and act upon them.
If you really want to make it nice and clean, you can separate out the code that accepts incoming requests to do something, checks if it can be performed now, does it or stores it for later, and periodically checks any requests in the pending queue. This class will not have any idea what the requests do or how they are performed, it will work with another class that implements a protocol to do the actual work and knows about facebook, etc. There may even be an existing design pattern for such a setup, but I don't know what it's called if there is.
Update: I did some research and found this is very similar to the "Fire-and-Forget Pattern".

Resources