iOS Google+ Safari cannot open page because address is invalid
Asked Answered
L

3

20

I have two apps one is free and another is paid version. I have implemented google+ share on paid and its working fine. But when I copied code to my free version it doesn't work. I have one Google apis project and added two clients for both iOS apps.

I get "Safari cannot open page because address in invalid" erro after sharing or cancel and it does not open my app.

Please help

I followed all steps defined at https://developers.google.com/+/mobile/ios/share#detecting_if_a_post_was_successfully_shared

Lalia answered 13/6, 2013 at 6:12 Comment(0)
W
6

Add this method into your appdelgate

  - (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
NSLog(@"%@",sourceApplication);


// Handle Google+ sign-in button URL.
if ([signInButton_ handleURL:url
           sourceApplication:sourceApplication
                  annotation:annotation]) {
    return YES;
}



 return NO;
}
Watusi answered 13/6, 2013 at 6:20 Comment(5)
use of undeclared identifier 'signInButton_', do i need to declare it somewhere in appdelegate's .h file ?Peter
have you declared in yourviewcontrolle.h file? ... and add class @class GPPSignInButton; in you view controllerWatusi
well, I have a custom button, on its click i give a call, [signIn authenticate]; However even after logging in properly , - (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error isn't getting called. I have placed - (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation { return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]; } in my appdelegatePeter
Why are you using custom button , you can change images of GPPSignInButton. have you set delgate? i.e.signInButton_.delegate = self;Watusi
#14037337 this helped me :) Cheeerrrrsss...!!! :DPeter
H
17

Make sure that you add a URL Type for your app and that it matches the bundle ID of your app. I made a typo in specifying the URL and it took me a while to figure out why it wasn't working. https://developers.google.com/+/mobile/ios/getting-started#step_3_add_a_url_type

Hitt answered 11/10, 2014 at 22:34 Comment(0)
P
12

For this we have to add URL schemes and identifier value in ProjectName - settings tab - info tab - URL Types tab.

Like in the below screenshot

enter image description here

Pros answered 12/10, 2015 at 6:48 Comment(3)
Yes i added a description with link.first i mentioned in words and after that i provide an image for an example.Pros
Thanks for Proper correction.Now this is 100% valid Answer.Pros
Adding identifier and URL Scheme matching project name solves my problem. Thanks!Sauceda
W
6

Add this method into your appdelgate

  - (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
NSLog(@"%@",sourceApplication);


// Handle Google+ sign-in button URL.
if ([signInButton_ handleURL:url
           sourceApplication:sourceApplication
                  annotation:annotation]) {
    return YES;
}



 return NO;
}
Watusi answered 13/6, 2013 at 6:20 Comment(5)
use of undeclared identifier 'signInButton_', do i need to declare it somewhere in appdelegate's .h file ?Peter
have you declared in yourviewcontrolle.h file? ... and add class @class GPPSignInButton; in you view controllerWatusi
well, I have a custom button, on its click i give a call, [signIn authenticate]; However even after logging in properly , - (void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error isn't getting called. I have placed - (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation { return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]; } in my appdelegatePeter
Why are you using custom button , you can change images of GPPSignInButton. have you set delgate? i.e.signInButton_.delegate = self;Watusi
#14037337 this helped me :) Cheeerrrrsss...!!! :DPeter

© 2022 - 2024 — McMap. All rights reserved.