Spotify SPTAuthViewController issues - ios

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

Related

iOS Document Sharing: "Save to Dropbox" always fails

Posting after finding answer
After "rubber duck debugging" this answer a bunch, I finally came across the correct answer on a question that appears to me to be unrelated. I think this question (and its answer) are still relevant, so I'm posting the question and will post my own answer to hopefully help others like me.
I am creating a PDF in my iOS app that I would like to allow the user to export. For the purposes of this testing, I'm trying to save it to my personal Dropbox on a physical device.
I have turned on iTunes file sharing, and I can verify that the PDF file is being generated correctly, and when I copy it off of my device (iPad Pro Gen. 2 running iOS 11), I can open the PDF and it has the expected content and appearance.
I am able to get the document pop-up to display correctly, and I have options to share via:
Line 1: AirDrop
Line 2: Message, Mail, Add to Notes, (Facebook) Messenger, etc.
Line 3: Copy, Print, Save to Files, Save to Dropbox, etc.
No matter what I try to select (Save to Dropbox is the one I want to solve, but the issue seems universal), it fails. Of note, when I click Save to Dropbox, I do see the Dropbox panel display, but there is immediately a modal over top of the Save to Dropbox modal that says, "An unknown error occurred."
I have tried to look around and see how to get more information about this error, but I'm stumped. I'm not sure if it's correlated, but I get this message in the console:
[AXRun-PID] Client requesting unsuspension of PID:813 Name:<redacted>
Trying to google that error has proved unfruitful.
Here's the code where I generate the PDF and show the menu:
#pragma mark • Sharing Methods
- (void)showShareMenu {
NSArray *bookList = [BookManager bookList];
NSURL *pdfUrl = [PdfGenerator generatePdfFromBooks:bookList];
UIDocumentInteractionController *vc = [[UIDocumentInteractionController alloc] init];
vc.name = #"Booklet.pdf";
vc.URL = pdfUrl;
vc.UTI = #"com.adobe.pdf";
[vc presentOptionsMenuFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];
}
I've tried using UIDocumentInteractionController *vc = [UIDocumentInteractionController interactionControllerWithURL:pdfUrl]; instead of the one above, but the results are the same.
I tried making self the delegate of vc and then tried to implement the following methods:
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
willBeginSendingToApplication:(nullable NSString *)application;
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
didEndSendingToApplication:(nullable NSString *)application;
Neither of those methods ever fired.
Interestingly, though I think I've supplied the file name correctly based on what I've read, the name in the File textbook in the Save to Dropbox modal is a current timestamp (e.g., File Oct 28, 11 12 22 PM). The Dropbox modal stays up until I click "OK" on the "An unknown error occurred" modal, and then disappears immediately.
It seems like I'm somehow not providing the right information, but I'm not sure how. It seems like there ought to be a delegate method to indicate an error to me, but I don't see anything like that in the docs. (It is late, and I have been looking at this for hours, including reading several related tutorials, so I could have missed something obvious.)
I came across this answer as an example question while asking this current question.
It doesn't really ask the same question I have, nor did that user have the same error outputs I did. But, the linked answer did work for me, too.
The problem I had in the code above was that I was not keeping the UIDocumentInteractionController around after I created it. Adding a private property fixed this issue. So, the following code now works:
#pragma mark • Sharing Methods
- (void)showShareMenu {
NSArray *bookList = [BookManager bookList];
NSURL *pdfUrl = [PdfGenerator generatePdfFromBooks:bookList];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:pdfUrl];
self.docController.name = #"Booklet.pdf";
self.docController.UTI = #"com.adobe.pdf";
[self.docController presentOptionsMenuFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];
}

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)];

iOS: Sign In with Google button

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

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