简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM