Can login with attemptLoginWithUserName: on Simulator, but not on iPhone - cocoalibspotify-2.0

I have a strange problem. After I logged in with the standard SPLoginViewController, I save the username and the credential. After I startup again, I try to call:
[[SPSession sharedSession] attemptLoginWithUserName:
existingCredential:
On the iOS Simulator (iOS 6.0), it works just fine. On my iPhone (iOS 6.0.1), it does not. SPSession is logging in exactly five minutes after I called the attemptLogin method. SPSession is also logging in when I put my app in the background.
Does anyone know more about this and maybe a solution?
Thanks

It appears there's a known bug in libspotify where sp_session_process_events() will sometimes return excessively high values in next_timeout. I've seen values such as 300100 and 300195 come out of the routine.
One workaround is to set your wait to the max of next_timeout and 50. (Or 100 or whatever your heart desires.) See https://github.com/spotify/cocoalibspotify/issues/140
I wish Spotify would start a known-issues list for libspotify. I wasted over a day trying to dig this one out. Hopefully this post will save someone else the same fate.

Related

Firebase Analytics seemingly works perfect, but just won't show up?

In a large app which uses Firebase extensively, I'm trying analytics,
-FIRDebugEnabled is set fine.
The date/time on the devices is set correctly.
I have tried all of simulator, tethered device, and even building through to TestFlight.
The needed stuff is in app startup ..
FirebaseConfiguration.shared.setLoggerLevel(.max)
FirebaseApp.configure()
// helps Analytics get going:
AnalyticsConfiguration.shared().setAnalyticsCollectionEnabled(true)
Again, Firebase realtime and database works perfectly throughout.
So using Analytics.logEvent# ...
Note that the items appear perfectly in Xcode console:
2018-07-24 08:27:23.868 Blah[7501] <Debug> [Firebase/Analytics][I-ACS023105] Event is
not subject to real-time event count daily limit. Marking an event as
real-time. Event name, parameters: select_content, {
firebase_event_origin (_o) = app;
firebase_realtime (_r) = 1;
item_name = tapMyProfile;
firebase_screen_class (_sc) = Blah.SomeScreen;
firebase_debug (_dbg) = 1;
firebase_screen_id (_si) = 8314738347840858914;
item_id = Blah-tapMyProfile;
content_type = tapMyProfile;
}
or ...
2018-07-24 08:56:12.393306-0500 Blah[7501:135963] [Firebase/Analytics][I-ACS023073] Debug
mode is enabled. Marking event as debug and real-time. Event name,
parameters: select_content, {
firebase_event_origin (_o) = app;
firebase_screen (_sn) = MyProfile;
item_name = tapCamera;
firebase_realtime (_r) = 1;
firebase_screen_class (_sc) = Blah.OldDevDotScreen;
firebase_debug (_dbg) = 1;
firebase_screen_id (_si) = 8314738347840858915;
item_id = Blah-tapCamera;
content_type = tapCamera;
}
Notice tapMyProfile or tapCamera, one of my custom events from Analytics.logEvent#
Analytics as such does seem to be working perfectly:
so, those numbers update every few hours etc.
Again every item appears perfectly in the Xcode console ..
But no matter what, nothing will show up on the Firebase debug console!
Nothing!
What the hell could the problem be?
(Additionally I have waited a day or more and they don't show up as events either.)
How can it be that just nothing is showing up in Debug???
TL:DR - Delete your app from your device / simulator, rebuild and launch from XCode.
I faced this exact same issue even though Firebase and Firebase Analytics in particular seemed to be set up perfectly.
I cannot give the exact logical explanation yet as to why this worked, however one hint came from this Firebase events tutorial at around 5 mins 30.
He mentions that the -FIRAnalyticsDebugEnabled settings get saved to disk.
So after configuring & integrating Firebase, I ran my app which was already installed to test everything works fine and it did but the Firebase Console did not show me any messages of app events.
It's good to double check that you are not using special characters when sending your events and also not going over the character threshold, however even if you make these errors, you should see default events of screen_open, app_open, user_engagement which were not showing up for me.
My only theory is that launching the app from an already installed state does not impact the new settings of -FIRAnalyticsDebugEnabled.
So when I deleted my app, re-build and run from XCode, the events start showing up.
Finally, while testing, you might use another device and you might wonder, I was seeing my events from the previous device but nothing happens for the next one which baffled me for a few moments, remember to switch the device
However, in conclusion, I can say this behavior is far from reliable and because after a period of time (2-3 hours) when I ran my app again, nothing showed up on the Firebase Console again as if -FIRAnalyticsDebugEnabled had been disabled.
Deleting and reinstalling worked again.
Update for 2022
The above steps still applies. Just 2 more additions of why you might not see events you seem to be logging successfully:
Do a clean + build + run
There are some keywords that seem to not get logged because they are probably already in use by the Analytics framework. For example when I was trying to track a search event and one of the keys in my parameters dictionary was keyword and this never seemed to get tracked so use something else and give it a go
Check your device's time setting. Time needs to be accurate.
Did you enable Debug View for your app?
As per the docs, there is a minor difference on enabling debug events on the real-time and debug view that is embedded into Firebase Console UI.
To enable Analytics Debug mode on your development device, specify the following command line argument in Xcode :
-FIRDebugEnabled
For real-time logs on XCode console for the Arguments Passed On Launch section, add:
-FIRAnalyticsDebugEnabled.
It is been a long time since this question has been post. I have been struggling with this problem for over a week.
Everything was ok in my side, I saw it worked, like yours, in the Xcode debug mode. My issue was I did not look to the Debug View which is under the Analytics -> DebbugView in Firebase Console
Here is Debug View at the end of the analytics: Debug View
Documents in Firebase is here: In the firebase documents but the image is old.
It is in Analytics -> Debug View
Hope this will help someone!
Simply select which device you want from this "DebugDevice" dropdown menu. It's on the top left corner.
(It was driving me crazy for couple of hours! I hope Google will improve the UI of Firebase)
Make sure that the logged event name is longer than 40 characters, there is a limit for the length of the event name and parameter name.
https://support.google.com/firebase/answer/9237506?hl=en
Maybe it's not related to the question above, but I think it could help someone. Here's my case:
I was misunderstanding about when the user engagement update, I was thinking that it would be updated immediately after I've sent the event!
But it's not. You must to wait.
If you're wondering that, have you been successful sent the event to the board or not. You should check on the Debug-View section.

GameKit Error says player not authenticated but .authenticated property = true

I have an turn-based game using GameKit in iOS. Generally, my authentication with Game Center works. My game works and I can for periods of time send moves back and forth. However, relatively frequently but not constantly, when I try to perform an action (e.g., finding a new match) over Game Center it fails with the error:
Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo={NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}
Yet, the GKLocalPlayer.localPlayer().authenticated = true, both immediately before getting the error and after. After getting this error, the authentication viewController does not get presented and GameKit methods that rely on authentication cease to function (they don't come back to life ). Then, if I send the app to the background and then bring it back to the foreground, the error does not return when I retry the action (without requiring new login and password entry).
According to this similar observation:
GKLocalPlayer authentication not working, but isAuthenticated returns YES (Game Center sandbox)
"1.Game Center fails to complete authentication if your device has incorrect dates. So, go ahead and check the current date.
You might have done this. I trust you - iOS Simulator >> Reset Content and Settings"
I am getting this problem on the device, not the simulator, ruling out #2. Could someone help me with #1? I may be naive here, but my iPhone and iPad have the right time and date. Is there something or somewhere else I should be checking and setting?
Then, if this is not the issue, what else could be the problem? I am running iOS9.
I've seen this too, and have an open bug with Apple. In my case, I'm testing with multiple physical devices, and only one of those devices ever encounters this. On that particular device, I'm logged into iTunes using a personal account, but logged into game center using a test account.
From what I can see, when the device is using the same login for iTunes, iCloud and game Center, there are no problems. But, when I try to mix-and-match the accounts for whatever testing I need to do, then I randomly get error 6.
There doesn't seem to be anyway to recover from this, except to have the user re-login into game center. Of course, there's no way to present the login view controller again, so the only option is for the user to leave the game, kill it off, and star up again (which re-starts the game center authentication process). I trap the error now, give the user a message saying Game Center has logged them out, and explain what they need to do about it.
But as I said, when I stopped mixing up credentials on the device, the problem went away.
BTW, on a slightly related topic, I've come to view the .authenticated property as completely unreliable. It will be TRUE in conditions where you do not actually have connection to Game Center. I opened a bug on this, too. Apple closed it saying this was working as intended by using "cached" data. Thus, it will report authenticated when it's not authenticated and give you access only to outdated match and leaderboard data which had previously been saved locally.

NSUserDefaults Values Are Lost Periodically

I use [NSUserDefaults standardDefaults] to store a boolean to see if it is the first time that application is being launched ... If so, the app should show a registration window.
It was working fine till last week, but now, sometimes when I switch to other apps and come back after a little while, I see that registration page loads while it shouldn't.
I used NSLog to see what is stored in [NSUserDefaults standardDefaults] and I see that the values I stored has been set to nil (null) while I haven't done that anywhere in my code.
Does anyone know why the values do reset ?
P.S: Actually the values are not permanently lost , because if I don't do anything in registration page and quit the app instead, It will launch normally the next time I enter the app !!!
A long time ago I encountered this issue, turns out a third party library that I was using uses the same key when storing values to NSUserDefaults. Try searching your project for this key, maybe something else is resetting it.
Here are the ways I know about to lose values in NSUserDefaults, in order of likelihood:
The key was never saved in the first place
Your app deletes it later on
The app is deleted and reinstalled
Another app overwrites or removes the key
The phone or simulator is reset
During the night, the phone is replaced by an identical-looking, different phone
It sounds like, from the discussion here, that you've ruled out 1,2,4, and probably 3 & 5. The only next debug step I can think of is to store the test phone in a locked drawer at all times.
But I'd leave my money on an intermittent problem causing #1. For that, we'd need posted code to investigate.
EDIT -
A high % of NSUserDefaults problems posted here are about storing BOOLs and other scalar types. It looks like the OP knows about wrapping in NSNumbers, but BOOLS in particular are fraught because it's easy to confuse false-y values like NO no and nil, and NSNull instance.
Let's throw that on the list for this question at #2.5. There again, would need code to confirm.
If this is happening while testing, it's normal. The fact that the program is even making this decision (should I show the registration page?) suggests that the app has been forcibly quit and is starting from scratch. When testing, this can result in clearing out the app sandbox as the app is reloaded from Xcode. In the real life of a real user, however, that won't happen (unless the user deletes the app from the device).
Make sure you are calling [[NSUserDefaults standardUserDefaults] synchronize] just after setting preferences and you are not overwriting you preferences.

Unity ios game get killed in background when login into Facebook

i've met a problem when integrating my game with Facebook Unity SDK, the latest version, on IOS7, IPhone-4s.
Each time the game requests a Facebook login operation, game will become inactive and turns into background, and a Facebook login page appears, then IOS will killed my game, even the memory used by that game is only 90M or so. After login completed, IOS re-launched game, at which time Facebook SDK couldn't find the previous game process who performed the login operation and thus the login result could not be passed into new game instance.
So, there are two questions:
1) Is there any way to make game process alive in background? I have no idea why 90M memory usage is large enough that IOS want to kill my process.
2) Is there any way let the new game process get login result performed by the previous game process?
3) Is there any way to open embedded webView login dialog of Facebook in unity when performs a login operation instead of jumping out my game?
thanks you.
------------ UPDATE ----------
Solution found for the 3rd question:
1) Locating Facebook/Editor/iOS/FbUnityInterface.mm
2) Find method -(void)login:(const char *)scope { ... }
3) change
openWithBehavior:FBSessionLoginBehaviorWithFallbackToWebView
to
openWithBehavior:FBSessionLoginBehaviorForcingWebView
4) now, each time you request login, an embed web-view dialog will be popped out instead of jumping out of current game to Facebook login dialog.
1) First of all make sure that you haven't checked 'PlayerSettings | Other Settings | Configuration | Exit on suspend' option, which kills your app when you leave it.
90MB on iPhone4S could be quite a lot, the device itself has only 512 MB RAM memory, where system takes a lot. If you have many apps open, then your app, then facebook app which nowadays is not lightweight as well, then the biggest active process (your game) could be killed.
2) Yes there is. Facebook Unity3d plugin has a method for checking the logged status, which should return true after succesfull login (even if the app was killed).
if( FB.IsLoggedIn )
{
// your code here
}
3) There is no easy way to do that with current version of Unity3D Facebook plugin.
Try making a debug build in Xcode and see what it says when the application is killed in the background. It should give a stacktrace to see what happens. That 90MB shouldn't be a problem for an iPhone4S so out of memory crash could be ruled out.

getCurrentPosition does not refresh

I have an app which uses forge.geolocation.getCurrentPosition. It seems that at times, the location does not refresh. I can open the iOS app in one position, and then an hour later 5 miles away, open the app again (either resume, or completely close the app from the tray, and re-open) and still the old location is returned.
I am using this form
forge.geolocation.getCurrentPosition({enableHighAccuracy: true}, function (location) {})
Note that when opening/resuming the App, the GPS icon at the top DOES show up however the location returned to the javascript code is incorrect.
The above bug was reproduced on iOS 6
After opening the Maps app, and going back to my app, the correct location is finally returned.
Any idea how to fix this?
getCurrentPosition returns the best data it has at that particular time - I'd recommend calling the method a number of times until the indicated accuracy is reduced to an acceptable level.
What we might do in the future is support watchPosition so that something like https://stackoverflow.com/a/8554835 would be possible through the forge API

Resources