Google Plus Sharing from iphone - iphone

I need to share users posts from my iphone app to google+. I did facebook and twitter share.
Does google+ have an API for this? Does anyone have any examples?

Here is the link for the API of Google plus:
https://developers.google.com/+/api/
& here is the link where u can find help for sharing in google plus
http://code.google.com/p/google-api-objectivec-client/wiki/Introduction

For Swift 3.0
import SafariServices
then add the delegate
<SFSafariViewControllerDelegate>
use this below code in the share button
var urlComponents = URLComponents(string:"https://plus.google.com/share")
let queryItem = URLQueryItem(name: "url", value: "https://myexamplepagetoshare.com")
urlComponents?.queryItems = [queryItem]
let url = urlComponents?.url
let safariVC = SFSafariViewController(url: url!)
safariVC.delegate = self
self.present(safariVC, animated: true, completion: nil)
This is the simple G+ share that's available now.

The easiest way of sharing the posts on google plus is to first include its GPPShare.h file in xcode and then extend the .h file with GPPShareDelegate
And then write this code in the IBAction method
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
// This line will manually fill out the title, description, and thumbnail of the
// item you're sharing.
[shareBuilder setTitle:#"Share" description:#"sharing" thumbnailURL:[NSURL URLWithString:#"http://25.media.tumblr.com/tumblr_m9p3n1vJmZ1rexr16o1_400.jpg"]];
[shareBuilder setContentDeepLinkID:#"rest=1234567"];
[shareBuilder open];
and also implement GPPShareDelegate method which is helpful in order to detect the successful sharing
- (void)finishedSharing:(BOOL)shared
{ if (shared) {
NSLog(#"User successfully shared!");
} else {
NSLog(#"User didn't share.");
}

Right now they don't have any API I think.They are soon going to introduce .I hope help you.
But not now.

You use the Google+ share link:
https://developers.google.com/+/plugins/share/#sharelink
"The share link is intended for native client applications... and
others who may not be able to use the +1 or share button"

I integrated Google plus sharing. Please see this code. https://www.dropbox.com/s/o0bwtzgbpobsjkq/Share.zip?dl=0

Related

CloudKit CKShare URL Goes Nowhere

I have successfully saved a CKShare URL to CloudKit, and I can see that the user is INVITED in the CloudKit Dashboard. My Mac app emailed the URL to that person, but when they click it, all they see it this screen on icloud.com:
Clicking OK makes everything disappear so all you see is the background on the web page.
My understanding is that the URL is supposed to open my Mac app where it will fire userDidAcceptCloudKitShareWith in my app delegate. But it does nothing.
Could this be because my app is in development and not in the Mac App Store yet? Do I need a custom URL scheme to get it to open my app?
Documentation on this stuff is pretty sparse. I'd love any help someone can provide.
I have since learned that you must specify a fallback URL for your CloudKit container. In cases where the app isn't installed (or isn't recognized, which seems to be the case when doing dev builds in Xcode like I am), CloudKit will forward share URL to somewhere you specify. They append the unique share ID to the URL so that you can process it on your own web page.
In the CloudKit dashboard, go to Environment Settings... and you'll see this popup:
I have it redirect to https://myapp.com/share/?id= and on my web page where it redirects to, I do a $_GET['id'] to grab the id. I then do another redirect to my application using a custom URL scheme and pass the share ID (e.g. myapp://abc123 where abc123 is the share ID).
In my app delegate, I receive the URL like this:
func application(_ application: NSApplication, open urls: [URL]) {
if let url = urls.first, let shareId = url.host{
fetchShare(shareId) //<-- sharedId = abc123
}
}
I then use CKFetchShareMetadataOperation to look up the URL of the share and CKAcceptSharesOperation to accept it like this:
func fetchShare(shareId: String){
if let url = URL(string: "https://www.icloud.com/share/\(shareId)"){
let operation = CKFetchShareMetadataOperation(shareURLs: [url])
operation.perShareMetadataBlock = { url, metadata, error in
if let metadata = metadata{
//:::
acceptShare(metadata: metadata)
}
}
operation.fetchShareMetadataCompletionBlock = { error in
if let error = error{
print("fetch Share error: \(error)")
}
}
CKContainer.default().add(operation)
}
}
func acceptShare(metadata: CKShareMetadata){
let operation = CKAcceptSharesOperation(shareMetadatas: [metadata])
operation.acceptSharesCompletionBlock = { error in
if let error = error{
print("accept share error: \(error)")
}else{
//Share accepted!
}
}
CKContainer.default().add(operation)
}
I think there are easier ways to work through this using NSItemProvider and NSSharingService, but I'm doing a lot of custom UI and wanted to have full control of the share workflow.
I hope this helps someone. :)

ios app rejected on using AWS cognito implementation from mobile hub

We recently got our ios app rejected because of the following:
We noticed that the user is taken to Safari to sign in or register for an account, which provides a poor user experience.
however, the bit that launches the safari window for facebook/Google login is part of the AWSMobileHubHelper framework so we can't modify that code.
Any ideas/solutions would be greatly appreciated.
So I found a workaround. I just grab the GIDSignIn instance and change the properties myself. In case any one else wants to know how, all you have to do is:
Add a bridge header and import #import <GoogleSignIn/GoogleSignIn.h>
Implement the presentViewController method for GIDSignInUIDelegate on your main login controller
func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) {
presentViewController(viewController, animated: true, completion: nil)
}
Edit demo login code to be something like this:
func loginWithGoogle(delegate: GIDSignInUIDelegate!) {
let googleProvider = AWSGoogleSignInProvider.sharedInstance()
// It is important that these are initialized after
// AWSGoogleSignInProvider.sharedInstance() is called
GIDSignIn.sharedInstance().uiDelegate = delegate
GIDSignIn.sharedInstance().allowsSignInWithBrowser = false
GIDSignIn.sharedInstance().allowsSignInWithWebView = true
handleLoginWithSignInProvider(googleProvider, callback: callback)
}
As of iOS 9 using Facebook SDK, this is expected behavior per Facebook login. Mobile Hub quickstart app is just applying the Facebook SDK 3 and using the APIs as directed. Check out the brief description below and read through the comments to get a better insight. This was not a popular decision by Facebook and others have provided workarounds (to forcing user authentication via mobile browser) if you wish to experiment. As for the AWSMobileHubHelper framework, we are looking into making this available at some point but don't have a timeline for this.
"Logic that automatically defaults people to the optimum experience for iOS 9. This means that the SDK dialogs for Facebook Login, Sharing across Facebook and Messenger, App Invites, App Events, or Native Like will automatically determine the best experience for people based on their device."
Source:
https://developers.facebook.com/blog/post/2015/09/10/new-SDK-for-iOS9/

Opening Facebook event pages in the Facebook app using Swift

I am having a problem getting Facebook events in the Facebook app. For example, to open an event with the url "https://www.facebook.com/events/1743847059178738/," I would use the following code:
let facebookURL = NSURL(string: "fb://event/1743847059178738")!
if UIApplication.sharedApplication().canOpenURL(facebookURL) {
UIApplication.sharedApplication().openURL(facebookURL)
} else {
UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)
}
}
It will open the Facebook app, but no matter what event I attempt to display I get a screen saying "Unable to load event. It may have been cancelled." I have tried substituting the Facebook URL of an event for that of a profile (e.g., string: "fb://profile/100005906912309") and it works just fine. Am I mistaken in assuming that the numbers at the end of the event's URL are the same as the event's numeric ID?
So I figured out that I could bypass the whole "fb://event..." bit and just go with:
UIApplication.sharedApplication().openURL(NSURL(string: "https://www.facebook.com/events/1743847059178738")!)
I assumed this would open the link in Safari, but it automatically opened in Facebook in iOS 8.
I'm sorry for the late answer. I'd prefer to write this as comment, but I'm not able to.
First, nice work around. I think it is a perfect fallback if the fb:// scheme fails as it shown in code shared with your question. I've spent a lot of time trying to resolve the same issue. What I've found is that fb://event/{event-id} is no longer supported and it was replaced with fb://event?id={event-id}.
I've used this post as a reference.

Sharing on WhatsApp in iOS 9.0

I m new in iOS development and i want to integrate WhatsApp sharing in my app in ios 9.0 . i have searched various methods but they all are depreciated in ios 9.0
Can anyone suggest me updated method for the same,
#IBAction func whattsappInvite(sender: UIButton)
{
let urlString = "Hello Friends, Sharing some data here... !"
let urlStringEncoded = urlString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
let url = NSURL(string: "whatsapp://send?text=\(urlStringEncoded!)")
if UIApplication.sharedApplication().canOpenURL(url!) {
UIApplication.sharedApplication().openURL(url!)
}
}
Apple changed the canOpenURL method on iOS 9. Apps which are checking for URL Schemes have to declare these Schemes as it is submitted to Apple. Else canOpenURL returns false.
Add whatsapp field in LSApplicationQueriesSchemes in info.plist of your app.
Or try using whatsapp share extension
To share with Whatsapp, you can use your code or this one as a base :
var whatsappURL:NSURL?= NSURL(string: "whatsapp://send?text=Hello%2C%20World!")
if (UIApplication.sharedApplication().canOpenURL(whatsappURL)) {
UIApplication.sharedApplication().openURL(whatsappURL)
}
None of these methods are deprecated in iOS 9.0.

iOS Google+ App not returning back to app after user select Share or Cancel

I have an google+ api app the logs into google+ and share just fine but it doesn't return back to the app after posting or canceling the post i tried debugging it and it does not enter the - (void)finishedSharing:(BOOL)shared {
- (IBAction)googlePlusPost:(id)sender {
SLServiceTitle = #"Google+";
/*[[[[share shareDialog] setURLToShare:[NSURL URLWithString:urlToShare]]
setPrefillText:textToShare] open];*/
[GPPShare sharedInstance].delegate = self;
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
// This line will manually fill out the title, description, and thumbnail of the
// item you're sharing.
// thumbnailURL is url of image you want to display.
[shareBuilder setTitle:#"Title of your post"
description:#"Description of your post"
thumbnailURL:[NSURL URLWithString:urlToShare]];
/* This line passes the deepLinkID to our application
if somebody opens the link on a supported mobile device */
[shareBuilder setContentDeepLinkID:#"share"];
// set the text of post. user can edit this before sharing.
[shareBuilder setPrefillText:textToShare];
[shareBuilder open];
}
This is a problem in Google plus SDK. This is a link where the issue is opened:
https://code.google.com/p/google-plus-platform/issues/detail?id=794&can=8&colspec=ID%20Type%20Status%20Component%20Owner%20Summary%20Stars
I need to look into your code. Please post google+ related code. You can refer to my answer on this question.
You need to first login in g+ then share video on g+ using native app dialog.
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
This will open native window in your own application.
Reference : https://developers.google.com/+/mobile/ios/share/deep-link