How to share URL using Xamarin iOS - ios

I'm developing an app for my local newspaper. When you press the "Share" button, I want the standard iOS share interface to appear allowing users to share the URL of an article with Facebook, Twitter, etc. I'm trying to use the UIActivityViewController, and while it appears, it's not giving me all of the options.
Here's the code I use:
NSObject[] activitiesItems = {
new NSString(post.Title),
new NSUrl(post.URL)
};
var activityController = new UIActivityViewController(activitiesItems, null);
PresentViewController(activityController, true, null);
When the UI opens, this is all I see (no Twitter or Facebook):
This is in comparison to what I see when I share a page from Safari, which has the Facebook and Twitter options, along with a variety of others:
What do I have to change in my code to allow more of these options to appear?

1) Your code is fine
2) On your iOS Simulator go to the Setting and login to Twitter and/or FaceBook accounts and retest your app.
iOS Simulator Setting (botton off screen):
Here is my Simulator view with me logged into Twitter but not Facebook using the same code you posted:
3) Safari is a using a custom ViewController to display what you are seeing... If you actually try to share a link via that Twitter button you will be force to login..
4) Use an actual device for complete testing of all the possible sharing applications installed.

Those options are only supposed to show when you are logged in to an account in the Settings app for FB and Twitter. They are hidden if not.
However that doesn't really explain why they show up in Safari.
Perhaps including the NSString for post.Title in the items array is causing it to exclude some sharing options.

Related

Unable to like using Facebook iOS SDK

I am trying to implement like in my Objective C application. If I am not logged into Facebook, then after tapping Like button, application opens login screen. I will log into my account. Then screen goes light gray with gray logo of Facebook for a while (with 2 shortly showed grey facebook screens before that) and then I am redirected back into my app. If I am logged into Facebook when running application, everything is the same except not showing login screen.
So my problem is, that I am not getting correct confirmation dialog that should appear after logging into FB account and I am redirected back into my app. Like is not placed.
What can be cause of this behaviour?
I have placed all 3 needed rows into .plist and this is how I am creating like button (p_webView is my subclass of UIWebView):
if (p_webView.fbLikeButton == nil) {
p_webView.fbLikeButton = [[FBSDKLikeControl alloc] init];
}
p_webView.fbLikeButton.objectID = p_webView.article.url;
[p_webView.fbLikeButton setFrame:CGRectMake(p_webView.fbLikeButton.frame.origin.x, height + 5, p_webView.fbLikeButton.frame.size.width, p_webView.fbLikeButton.frame.size.height)];
[p_webView.fbLikeButton setCenter:CGPointMake(p_webView.frame.size.width / 2, p_webView.fbLikeButton.center.y)];
[p_webView.scrollView addSubview:p_webView.fbLikeButton];
More information - I have tried this on simulator (there I do not have FB app, so it was using Safari only). After loggin in, I have got error:
"The page you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may be broken or expired, or you may not have permission to view this page."
As it might be difficult to find solution - one needs to be in FB app as administrator, developer or tester for like button to work when testing app that has not been approved by Apple for using native like button yet.
You are doing right.
Maybe you are missing something:
You have to create fb app id and add it to iOS app. So you can open fb app when tap on Like button.(I think you did this)
You have to add your fb acc (using to login) to dev/test roles in your fb app. If not you will be pushed back to iOS app after login to fb (in fb app or safari). <--- I think your problem is here.
Ref: https://developers.facebook.com/docs/apps/test-users
If you want everyone can login and like, you have to Submit Your App for Review (with Native Like button). After that, everyone can use Like button.
For the fb app setting, in the "Status & Review" tab, turn on "Do you want to make this app and all its live features available to the general public?"
After that you can see this "This app is public and available to all users" in Dashboard tab, instead of "This app is in development mode and can only be used by app admins, developers and testers"

SLComposeViewController won't set initialText for SLServiceTypeFacebook

It seems as a bug in Social framework, it won't set the initial text for Facebook service type. This is my implementation using Swift:
let view = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
if view.setInitialText("Some text") {
NSLog("Success")
} else {
NSLog("Failure")
}
view.addURL(NSURL(string: "https://google.ro"))
self.presentViewController(view, animated: true, completion: nil)
What it works:
The URL shows up for both, Facebook, and Twitter
The initialText works correctly just for Twitter
What is doesn't work:
The initialText won't show up for Facebook, even though the code above outputs "Success"
Update 2
It seems like Facebook really doesn't want developers to set the initial text of a message when Sharing as that it's impossible even with their SDK. In the app I was implementing I've chosen screenshots from the app (uploaded as images) for letting the user share their progress on Facebook.
Update
The solution is to use the Facebook SDK for iOS, that feature of Social framework is not supported by Facebook anymore.
Not a bug, Facebook doesn't allow it anymore.
Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.
Facebook dose't allow to pre fill message anymore.
For more info here
Saying that, if you use native Facebook sdk it won't solve your problem, because Facebook will not publish your app.
So as written on Facebook guidelines, the only solutions that you have are:
Populate the user message parameter with content that the user manually entered earlier in your app's flow.
Your app’s composer can include a call-to-action that disappears when people start to write a post. For example, Facebook's composer uses grey scale text to ask “What's on your mind?” that disappears when people start to write.
I think it is an iOs 8.3 bug.
Before I updated to that version it was working correctly. :-(

iOS Facebook Like Button Not Working With iOS App

Trying to add the Facebook Like Button to an iOS App. Followed the directions online and am seeing an issue.
Without the Facebook App Installed on Simulator (8.x, 7,x):
When pressing the F Like button, we see a transition to Facebook.com but then quickly returns to the iOS App. It does not go to the proper Facebook Like page where the user can like the URL passed.
In the iOS app, the openURL method is being called and the Facebook
wasHandled = [FBAppCall handleOpenURL: url sourceApplication: sourceApplication];
is being called and it returns YES.
Please note that we are also using the Facebook Login Button that is working fine in this app.
The user has already been authenticated with the Facebook Login Button at this point.
Any hints on this would be appreciated.
We are using Facebook iOS SDK 3.21.1
[Addition]
See this article
http://stackoverflow.com/questions/26529314/android-likeview-error
This is what we are seeing in the the URL Error Message in openURL
The like dialog is only available to developers and testers
Which kinda does not make sense? Regular users should be able to see the like dialog to like the item?
For Facebook Like Buttons on iOS and Android.
After you have integrated the latest SDK and you want to test....
1) You must use a Facebook Account that is either the Developer account for the app (the account that the Facebook ID for the app was created) OR a linked tester Facebook account to the Facebook Developer account.
2) You have to use this account to login with on for the App.
3) When testing a "BETA" banner will be on the target page.
4) If these are not in place, for iOS at least you will get an error message in the URL in the openURL routine in the AppDelegate. For Android you will get a "CANCEL" status in your onActivityResult routine.
The like dialog is only available to developers and testers
Hope this helps.
To fully enable the like button for production, please see Ming Li comments above.

break website out of iframe/uiwebview on iphone twitter client?

when we click on a link to our site, www.tekiki.com, from inside the twitter iphone client (search for tekiki.com on the twitter mobile client), the site appears in a boxed area.
is this an iframe or something we can break out of? we tried iframe-busting code, but it fails. we suspect this is a uiwebview. if true, can we bust out and open the site in safari/chrome via javascript?
When you click on a link within the official Twitter iOS app, it opens up a new modal view that contains a UIWebView. There is no way that you can break out of this view and into a different app since Twitter controls the experience. iOS only supports fast app switching via registered URL schemes such as fb://1234567890, not via javascript, etc.
The only way would be if they had an additional button that gave the user the option to open the page in a different app.

Create iOS link to an App in the app store - best way?

Here are my requirements:
1. Create links to a single app in the app store 2. Access the links either from inside an app, on the device generally (e.g. mail link) or from a PC (e.g. via facebook share link) 3. Open links using iPhone or iPad running iOS 5+
I have done some digging around and come up with the following options:
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=487547243
http://itunes.apple.com/gb/app/anyValue/id487547243?mt=8
http://itunes.com/apps/seligmanVenturesLtd/mouseTrapFree
http://itunes.com/apps/mouseTrapFree
itms://itunes.com/apps/mouseTrapFree
itms-apps://itunes.com/apps/mouseTrapFree
Just wondering if one (or some) of these are better than other?
Thanks.
Ok, so have done a lot of research/testing and here is my conclusion:
Links you use in your code should not rely on the 'current' name of you app, since this might change over time (e.g. Light Alarm Lite vs Light Alarm Free). Therefore the following 4 are out IMHO:
http://itunes.com/apps/seligmanVenturesLtd/mouseTrapFree
http://itunes.com/apps/mouseTrapFree
itms://itunes.com/apps/mouseTrapFree
itms-apps://itunes.com/apps/mouseTrapFree
That leaves itunes and phobos URLs. I have just tested both URLs via the iOS 6 share functionality (so this might be different on iOS 5, but given numbers are reducing daily for that I dont really mind). I tested accessing via SMS, Email, Facebook, Twitter (on an iPhone 5 and using a Mac).
Both url types produced near identical results, except for the following:
Phobos:
e.g. http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=346542660
+ None
- Sharing this link on facebook created a facebook link without any image... this was the showstopper for me that will mean I use iTunes urls going forward (see below).
iTunes
e.g. http://itunes.apple.com/gb/app/appName/id346542660?mt=8
+ When opening link on iphone 'Mail' app the app store opened within the 'Mail' app and no tabs along the bottom appeared, so arguably this creates increased focus on your app
- None
In summary, I will be going with itunes type urls going forward. eg:
e.g. http://itunes.apple.com/gb/app/appName/id346542660?mt=8
(Note: you don't have to stipulate the '/appName' in this url, just keeping it as '/appName/' works fine, which means you dont have to worry if you app name changes over time.
Cheers, Charlie
URL/Link to an app on the app store can be created very easily but there are several ways to achieve the end result. First of all we need to be clear on the purpose of the link (For ex. link might be used for Facebook posts or used inside an app for urging users to rate the app through in-app alerts/buttons). We can broadly categorize how we will use the link in 3 categories:
1. We want to use the link publicly outside the iOS (or OS X) domain. Means you can use this link to share on your Facebook wall or you want to embed the link in mail. I said outside iOS domain because your friends who doesn't have iPhone (or any other iOS device) or MacBook they might also use click that link from Facebook or their mail app/client.
2. We want to use the link inside iOS (or OS X) domain. Means when we are certain that our link will be clicked by device using iOS or OS X.
3. We want to send the app user (already a user of our app) to specific section (like review section) of the app on app store.
For category 1 and 2 it's best to use this type of URL:
https://itunes.apple.com/app/dots-a-game-about-connecting/id632285588?mt=8
When you embed this link then it can result in several outcomes:
If user clicks on this link from iPhone (from any iPhone app or mail app on iPhone): Your app page on App Store will open directly
If user clicks on this link from any Android Phone or Browser (Chrome/Safari/etc.): Your app page on itunes.apple.com website will open inside default browser. Even if you are opening it on you MacBook it won't open iTunes App Store but will display you app page in Browser itself.
Side Note: There are several places on web where below mentioned sort of link is also suggested:
http://appstore.com/dotsagameaboutconnecting
When you embed this link then it can result in several outcomes:
If user clicks on this link from iPhone or MacBook: Your app page on App Store will open directly. So this link is a bit better for MacBook users as it send users of MacBook directly to iTunes instead of staying within Safari browser.
If user clicks on this link from any Android Phone or Browser (Chrome/Safari/etc.): If user is clicking from PC that has iTunes installed then this link will open your app on iTunes else (on Android devices and PC that doesn't have iTunes) it will open a Apple.com page displaying "Download iTunes" without any mention of your app. Screenshot of that page below:
So If you are not sure about who will click on your link (outside/inside iOS domain) or If you want to be on safer side then I recommend first approach. Read here on how to create specific link for your app.
For category 3 simply use below code in some function/action:
NSString *myAppID = #"632285588";
NSString *url = [NSString stringWithFormat: #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%#", myAppID];
//iOS7 doesn't approve above format so add iOS7 specific format
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
url = [NSString stringWithFormat: #"itms-apps://itunes.apple.com/app/id%#", myAppID];
}
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
For details on above code see this answer.
For developers who are developing first version of app and app is still not published on app store there is always a quandary about how to get the right link for your to be published app. For that:
Get your app ID from iTunesConnect. Use iTunesConnect to create your new app - give it a name, description, icon, screenshots, etc. Once app is created on iTunesConnect (without even submitting the app), you can get the Apple ID from the Identifiers section for the app.
You should not have any problems with the following one:
http://itunes.apple.com/gb/app/notebookpro/id<APP_ID>?mt=8
I believe, it will be opened on all major browsers/OS.
https://itunes.apple.com/app/id##app-id##?mt=8
Replace ##app-id## with real app-id.
For example:
https://itunes.apple.com/app/id346542660?mt=8
Summary
No country code. Ex: gb
No appName, only app-id.
https protocol.
I'm using the itms-apps: approach in our app, which also allows you to select to which "section" of your app the user will land.
So if you want to show them the reviews, this is what I use: itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXXXX
and for updating to the latest version of our app: itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=XXXXXXX&mt=8

Resources