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

160 views Asked by At

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];
}
2

There are 2 answers

2
Rizwan Shaikh On

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

0
Vineeth Joseph On

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