Search code examples
iosgoogle-mapsrestorestate-saving

ios restore state for google maps sdk GMSMapsView


I have developed an ios7 application with SWRevealViewController special for saving and restoring states (see: https://github.com/rochbu/SWRevealViewController). Now my app returns to the state where I left it - very nice so far. The problem is that I have a google map integrated in one of my sub view controllers and when I leave the app with the map on the screen it crashes when I restart it. So all other screens restore fine but the maps screen with GMSMapView crashes the app. It crashes 3 times and afterwards start with the rootViewController. Any ideas?!?

Cheers Fredrik


Solution

  • After I have struggled a lot of things I came to the solution... Well somehow stupid after all - I forgot to intitialize the Google Maps API Key when restoring:

    - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [GMSServices provideAPIKey:@"xxx"];
    }
    

    :( --> :)