ios - Share in google using GTLServicePlus with GIDAuthentication -
everything works before..
but i'm using new using googlesignin.framework
avoid rejection apple..
how can convert gidauthentication
gtmfetcherauthorizationprotocol
/gtmoauth2authentication
able use gppnativesharebuilder
?
update
sorry late update, created gtmfetcherauthorizationprotocol
/gtmoauth2authentication
using similar answer below by: @andr3a88 tried answer , working..
but still, cannot use gppnativesharebuilder
sharing without authenticating using gppsignin
, here error log:
[xxx/0x111533310] [lvl=3] -[gppnativesharebuilderimpl open] user must signed in use native sharebox.
the alternative solution did using gppsignin
, creating custom alertview informs user that:
"he leave application" , asks users confirmation..
but bad cannot submit app soon, we've have decided continue development go if our solution wont work , worst possible option removing g+ sharing...
if have solution allows gppnativesharebuilder
work gidsignin
, appreciated..
update 2
adding custom alertview asks users confirmation he's leave application did work , approved apple. cheers! :)
try in way:
add appdelegate (or wherever want) following property
@property (nonatomic,strong) gtmoauth2authentication *authgoogleplus;
then inside didsigninforuser call setauthorizerforsignin, method used create gtmoauth2authentication object used g+ api calls
- (void)signin:(gidsignin *)signin didsigninforuser:(gidgoogleuser *)user witherror:(nserror *)error { if (error) nslog(@"status: g+ authentication error: %@", error); [self setauthorizerforsignin:signin user:user]; } //add method used create gtmoauth2authentication - (void)setauthorizerforsignin:(gidsignin *)signin user:(gidgoogleuser *)user { //create gtmoauth2authentication gtmoauth2authentication *auth = [[gtmoauth2authentication alloc] init]; [auth setclientid:signin.clientid]; [auth setclientsecret:[[nsbundle mainbundle] objectforinfodictionarykey:@"googleclientsecret"]]; [auth setuseremail:user.profile.email]; [auth setuserid:user.userid]; [auth setaccesstoken:user.authentication.accesstoken]; [auth setrefreshtoken:user.authentication.refreshtoken]; [auth setexpirationdate: user.authentication.accesstokenexpirationdate]; //get app delegate , set gtmoauth2authentication appdelegate *appdelegate = (appdelegate*)[[uiapplication sharedapplication] delegate]; appdelegate.authgoogleplus = auth; }
now when make g+ api call sets gtmoauth2authentication object created during login
//get gtmoauth2authentication appdelegate *appdelegate = (appdelegate*)[[uiapplication sharedapplication] delegate]; gtmoauth2authentication * authgoogleplus = appdelegate.authgoogleplus; gtlserviceplus* plusservice = [[gtlserviceplus alloc] init]; plusservice.fetcherservice.timeout = 30.0; [plusservice authgoogleplus]; gtlqueryplus *query = [gtlqueryplus queryforpeoplegetwithuserid:@"me"]; [plusservice executequery:query completionhandler:^(gtlserviceticket *ticket, id object, nserror *error) { if (error) { if(error.code == -1001) { //timeout error } } else { //do user } }];
Comments
Post a Comment