Using Google+ SDK in iOS apps - ios

Google plus SDK has been integrated in one of my apps for sharing the app content.
For this user has to login into Google plus account on the app and then use this sharing feature.
But, in the Google developer site it says that Google Plus login is deprecated and we need to implement Google login instead of Google Plus login.
I am not using Google Plus just for a login functionality.
So, what should i do now?

There's a GoogleSignIn SDK: https://developers.google.com/identity/sign-in/ios/start-integrating.

If you are just interested in sharing you should probably be using the SFSafariViewController to present the share dialog box in a webview:
- (void)showGooglePlusShare:(NSURL*)shareURL {
// Construct the Google+ share URL
NSURLComponents* urlComponents = [[NSURLComponents alloc]
initWithString:#"https://plus.google.com/share"];
urlComponents.queryItems = #[[[NSURLQueryItem alloc]
initWithName:#"url"
value:[shareURL absoluteString]]];
NSURL* url = [urlComponents URL];
if ([SFSafariViewController class]) {
// Open the URL in SFSafariViewController (iOS 9+)
SFSafariViewController* controller = [[SFSafariViewController alloc]
initWithURL:url];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
} else {
// Open the URL in the device's browser
[[UIApplication sharedApplication] openURL:url];
}
}

Related

FBSDKSharingDelegate callbacks only work only with FBSDKShareDialogModeShareSheet - is this expected behaviour? [iOS 10 + 11]

I have been using code like this to share videos to Facebook:
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = assetURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = vc;
dialog.shareContent = content;
dialog.delegate = self;
dialog.mode = FBSDKShareDialogModeShareSheet;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) { dialog.mode = FBSDKShareDialogModeAutomatic; }
}
[dialog show]
where the delegate conforms to FBSDKSharingDelegate and implements these methods to track the result:
-(void)sharer:(id<FBSDKSharing>)sharerdidCompleteWithResults:(NSDictionary*)results;
-(void)sharer:(id<FBSDKSharing>)sharerdidFailWithError:(NSError*)error;
-(void)sharerDidCancel:(id<FBSDKSharing>)sharer;
I observe these callbacks working on iOS 10 for FBSDKShareDialogModeShareSheet, but in an otherwise identical implementation they are not called when using other dialog modes (for example) FBSDKShareDialogModeNative. In iOS 11, it doesn't appear that the share sheet mode is available anymore (presumably due to the Social Framework changes).
I don't have Facebook login in my app (nor any login), nor do I do anything to request FB permissions other than expect the user to authenticate within the native FB app. Is it expected that these callbacks will not execute in these other dialog modes, or is there something special I should do to get it them to work in this case?
The FB docs state
The delegate is notified with the results of the sharer as long as the
application has permissions to receive the information. For example,
if the person is not signed into the containing app, the sharer may
not be able to distinguish between completion of a share and
cancellation.
We are obviously passing the user to the native Facebook app in which they are authenticated - I'm not sure why this would work for one dialog mode and not for another. I'd rather not have to request the user login, as the whole point is to use the native FB app and let FB manage their own business internally.
Any help would be much appreciated. Thank you!

Facebook post do not open my application when i try from safari even though it works when using facebook application.

I have shared some content to Facebook and I am using this POC for that.
NSString *title = #"Some Title";
NSString *shareBody =[NSString stringWithFormat:#"%#\nI have rated %# as %zd/5", self.commentTextView.text, store.name, self.rating];
NSString *storeID = store.ID.description;
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentTitle = title;
content.contentDescription = shareBody;
content.imageURL = [NSURL URLWithString:store.coverImage.medium];
content.placeID = storeID;
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:#"https://fb.me/ 137144****85103?store=%#", store.ID]];
FBSDKShareDialog* dialog = [FBSDKShareDialog new];
dialog.delegate = self;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeBrowser;
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fbauth2://"]])
dialog.mode = FBSDKShareDialogModeAutomatic;
dialog.fromViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
Post is successfully shared to Facebook even if Facebook app is installed or not.
The first case is when I am using Facebook app and i click on the shared post, it opens my application(if it is installed) or takes me to iTunes URL.
The second case is Facebook app is not installed on my phone and I use safari to view Facebook and I click on that post. It tries to open the url but redirect me to facebook.com again.
The third case is Facebook app is installed on my phone but still I use safari to view Facebook and I click on that post, it opens facebook app instead of my app.
I need help for Case 2 and 3. Please advise ?

Facebook Deep Linking is not opening the app

I am sharing my post on Facebook. I am sharing Image, Content URL, Description. I am using this code for sharing:
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = APP_NAME;
content.contentDescription = text;
content.imageURL = [NSURL URLWithString:[[arrAllEvents valueForKey:#"flyer_image"]objectAtIndex:0]];
content.contentURL = url;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeFeedWeb;
[dialog show];
I have enable Deep Linking (News Feed links launch this app) option for https://developers.facebook.com.
I have added my Fbid and URLShema Like this
<key>CFBundleURLSchemes</key>
<array>
<string>abcevent://</string>
<string>fb1......</string>
</array>
and add code in appdelegate.m for the same like this
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url,NSError *error){
if([[url scheme] isEqualToString:#"abcevent"])
{
[self callNewsletter:url];
}
}];
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[FBSDKAppEvents activateApp];
}
Now if I am sharing my post on fb via application. That post click is not opening my app in iPhone Deep linking is not working.
Can anyone tell what other things I am missing with this?
The fetchDeferredAppLink method only works with ads. It never worked with links shared organically on the News Feed. You can read about more limitations of deep linking from Facebook in this blog post, but there are two core things to know:
Facebook has never supported deferred deep linking for non-paid content.
Facebook's App Links standard at one point supported normal deep linking (meaning if the app is already installed), but this has been broken on iOS for a long time.
If you want this sort of functionality, you'll need a separate solution like Branch.io (full disclosure: I'm on the Branch team).

Google plus iOS API to pre-fill data in share is deprecated, what is the alternative

I have to share text, url and image in Google plus from iOS app. Google plus sign in is deprecated and only basic sharing with text+url is available which is same as native iOS G + share. But I want to share image, url, etc., from my iOS app. Is any other way is possible to share media with text in Google plus now.
The Google share link supports two url paramaters: url for the target url, and hl for a language code.
- (void)showGooglePlusShare:(NSURL*)shareURL {
// Construct the Google+ share URL
NSURLComponents* urlComponents = [[NSURLComponents alloc]
initWithString:#"https://plus.google.com/share"];
urlComponents.queryItems = #[[[NSURLQueryItem alloc]
initWithName:#"url"
value:[shareURL absoluteString]]];
NSURL* url = [urlComponents URL];
if ([SFSafariViewController class]) {
// Open the URL in SFSafariViewController (iOS 9+)
SFSafariViewController* controller = [[SFSafariViewController alloc]
initWithURL:url];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
} else {
// Open the URL in the device's browser
[[UIApplication sharedApplication] openURL:url];
}
}

In iOS how we come back to initial view after google+ sharing?

I am implementing google plus sharing successfully by using the following lines of code. But after sharing it doesn't come back to initial screen. Is there any delegate call after completing the procedure of sharing
- (void)googelSharing{
//Set bool for Handler
[self setUserDefaultForSharing:NO];
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.clientID = kClientId;
signIn.scopes = #[#"https://www.googleapis.com/auth/plus.login"];
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
// This line will fill out the title, description, and thumbnail from
// the URL that you are sharing and includes a link to that URL.
[shareBuilder setURLToShare:[NSURL URLWithString:#"https://www.example.com/restaurant/sf/1234567/"]];
[shareBuilder open];
}
For your information Apple will reject the app if you use
a web page in mobile Safari for creating an account or logging in, then returns the user to the app.
See this discussion.
So Google release new Google Plus SDK for sign in
Google Sign In SDK 2.0 is documented on the new dev site :
https://developers.google.com/identity/sign-in/ios/
Hope this helps
It is not possible because when u request to open the specific web page iOS automatically transfer this request to Safari . And Safari will open that web page.
One thing you can do is used UIWebView in your app and open the web page inside UIWebView and u can easily get back to pervious viewController OR web page by adding simple UIButton in currentViewController class.
Here is code
UIWebView *webView = [[UIWebView alloc]init];
NSString *urlString = #"https://www.example.com/restaurant/sf/1234567/";
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlRequest];
[self.view addSubview:webView];
If u are used UIWebView than refer this answer it will help you Back Button on UIWebView

Resources