iOS: Sign In with Google button - ios

I am new to iOS development and working on a project where I want my users to login with Google.
I worked my way through Google's documentation, and could login in as well. All now I wanted was button/image which says "Sign in with Google" as
I looked through Google's SDK, but there is no exact image like that. so I tried to create my own which looks like
where ImageView is replaced with image in Google'e SDK.
Problem
When I run this, this doesn't look like it should
The red color of image and button do not match, neither I see vertical black line.
Question
a.) Where can I find the "Sign in with Google" button for iOS?
b.) The downloaded png might not work since as per the device we need two different resolutions #1x and #2x
Please let me know how can I get it?
UPDATE
- The problem was that the GooglePlus.bundle was not correctly loaded in my project. After fixing it, I see a button, but no text like
Has anyone seen this before?

You don't need an image that looks like this, just use the following code instead of that button and this will create a button as well as its action which will perform Google+ SSO for you.
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
//signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email
// You previously set kClientId in the "Initialize the Google+ client" step
signIn.clientID = kClientId;
// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = #[ kGTLAuthScopePlusLogin ]; // "https://www.googleapis.com/auth/plus.login" scope
//signIn.scopes = #[ #"profile" ]; // "profile" scope
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;
Just add the signIn button to your view and it should work. Here is the link in case you need any help
https://developers.google.com/+/mobile/ios/sign-in

Related

Spotify SPTAuthViewController issues

I am having trouble authorizing Spotify. The first time I believe I logged in but it froze up on the last page of the authentication process. Now when I try to log in, the popover is a blank screen. Also when I clear my cookies, the login screen appears but won't proceed past me entering my username and password. I appreciate the help here
I have tried doing this in both objective c as per the "Simple Track Playback" demo in the sdk and in swift using this tutorial http://pachulski.me/2015/spotifyframework-with-swift/
I was running into the same issue (blank popover). This was fixed when I added "App Transport Security Settings" (type: Dictionary) into the info.plist, and then implementing "Allow Arbitrary Loads" (Type: BOOL) and setting it to "YES".
Please refer to the screenshot:
EDIT: Added code to answer Brian's question in comments:
- (IBAction)loginButtonPressed:(id)sender {
_authVC = [SPTAuthViewController authenticationViewController];
_authVC.delegate = self;
_authVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
_authVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
self.definesPresentationContext = YES;
[self presentViewController:_authVC animated:NO completion:nil];
}

Xcode - Admob banner setting with targeting and test devices

I am working on my iOS app and trying to place a banner on the bottom of the page.
First of all, I set a BOOL (BannerAd) which is initially "NO" and set to "YES" when user hits the "Submit" button. By doing this tried to avoid requesting ads eveytime the user hit "Submit". This seems to work but world be nice if you can comment on it.
My interface has a "Datepicker" where the user selects his/her Birthday. I wanted to use this information for ad targeting. Also I know my application will be used in "Germany" so I set the location manually to "Germany" since my app doesn't request location information from user. And finally I am trying to test my app on my device where I set my test device UDID in "testDevices"
My problem is, I think my requests don't work. When I enter my own "adUnitId", I get paid ads on my device (which may cause a problem). Also when I tried to change the location, for example to "France", I still get local ads. I guess my location is not working and AdMob is using the network to determine the location. Which makes me think my "Birthday" information isn't working, too.
Below is the code I use and I don't know which part is wrong. I did researched and did everything according to the guides. I am not experienced and hoped that you guys can help me out!
Appreciated!
// Show Banner Ad
if (BannerAd == NO)
{
self.bannerView.adUnitID = #"ca-app-pub-3940256099942544/2934735716"; // TEST ID
self.bannerView.rootViewController = self;
NSDate *birthday =[datepick date];
GADRequest *request = [GADRequest request];
[request setBirthday: birthday];
[request setLocationWithDescription:#"Germany"];
request.testDevices = #[ #"b23cbd41317324cd9afd14dc848f2f0e" // TEST DEVICE
];
[self.bannerView loadRequest:[GADRequest request]];
BannerAd = YES;}
I can't understand your question(s) so good. Sorry.
If you want to put your adMob banner on the bottom of the screen, just use:
bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0,self.view.frame.size.height - 50, self.view.frame.size.width, CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height)];

Google+ API in iOS, GPPShare recipient setting

I am trying to integrate GooglePlus inside an iOS app of mine.
The app sends a simple message. I have a few questions about the setting of the recipient(s).
Here is the kind of code I am using:
[GPPShare sharedInstance].delegate = self;
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder setPrefillText:#"Hello world! How is everything?"];
[shareBuilder setPreselectedPeopleIDs:#"112233445566778899000"]; // Question point!!
if (![shareBuilder open]) {
NSLog(#"Status: Error (shareBuilder cannot open).");
}
When the line with the comment "Question point!!" is present, I can set one(or a few) individual(s) as recipient(s) of the message.
When it is not present the set of recipients defaults to "Friends".
Here are my two questions:
Is it possible to set one of my circles (or a community) as recipient? Not only "Friends".
When using the "setPreselectedPeopleIDs:" method, one needs the ID of the recipient. How do we find this ID? There are documents and videos on the net showing how to find one's own ID, but since people usually send messages to other peole rather than to themselves, it would also be useful to know how to get other's IDs.
Doesn't seem like you can share with a specific circle.
You can use this method to get all of the visible people in the user's circles using this method
queryForPeopleListWithUserId:collection:
which is outlined here:
https://developers.google.com/+/mobile/ios/people
Explanation of the parameters from the header:
// List all of the people in the specified collection.
// Required:
// userId: Get the collection of people for the person identified. Use "me" to
// indicate the authenticated user.
// collection: The collection of people to list.
// kGTLPlusCollectionVisible: The list of people who this user has added to
// one or more circles, limited to the circles visible to the requesting
// application.
And another question that goes into this a little bit:
How to Fetch Google Plus circles in IOS Sdk
It does not seem to me like you can discern who is in what circle, unfortunately.

ShareKit 2.0 facebook share URL

I have the following code for sharing with facebook using ShareKit:
-(void)buttonAction:(id)sender
{
[SHK setRootViewController:self];
SHKItem *facebookItem = [[SHKItem alloc] init];
facebookItem = [SHKItem URL:[NSURL URLWithString:#"www.google.com"] title:#"Some test title"];
facebookItem.facebookURLSharePictureURI = #"www.myTestPicture.com";
facebookItem.facebookURLShareDescription = #"Custom share description";
[SHKFacebook shareItem:facebookItem];
}
Everything works fine except for one scenario. My application has a log out button. Upon hitting this button, all the data save in NSUserDefaults gets erased. So, I log in and then make a post to facebook. Then, I log out (erase all the data) and afterwards log back in with facebook. Everything works so far. However if I try to make another post to facebook at this point, my application crashes with no error showing up in the console. If I restart the application and try to make the same post again, it works. It only crashed after loging out, back in (with facebook) and then trying to make the post. Any clues? Thanks.
EDIT: Seems like it is crashing in FBDialog at line 341:
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];
Ok, so after some digging aroung here, it seems to be Apple's bug in iOS 5.1 according to Why does clearing NSUserDefaults cause EXC_CRASH later when creating a UIWebView?

How to display "More games" page via ChartBoost in iOS?

I'm trying to integrate ChartBoost in my app and single ads are displaying OK.
This is the initial setup:
ChartBoost *cb = [ChartBoost sharedChartBoost];
cb.delegate = self;
cb.appId = CHARBOOST_APP_ID;
cb.appSignature = CHARBOOST_APP_SIGNATURE;
[cb showInterstitial];
But when I'm trying to display the "More apps" page, using the ChartBoost tutorial, I don't get the response.
-(IBAction) switchToMoreGames: (id) sender{
ChartBoost* cb = [ChartBoost sharedChartBoost];
cb.delegate = self;
[cb cacheMoreApps];
[cb showMoreApps];
}
I'd be very appreciative for any kind of help I can get, thanks in advance!
Since there were many requests for me to answer my own question rather than update it, I have created this answer.
To add "More apps" page you have to go to "Edit your app", then click "More apps page" tab and type the name of your campaign in the input field of the iPhone, which is showing on the right.

Resources