Hello,
Is there a way in Unity (I’m coding in C#), to get some process time to run a task in background when the app is put to background?
I’m looking for an equivalent of “beginBackgroundTaskWithExpirationHandler” function from iOS library, which if possible would work on both iOS and Android. Something to allow me to do the same as that:
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
myFunctionThatCouldBeLong();
}