DemoAppDelegate.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2016 Google LLC. All rights reserved.
  3. *
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  6. * file except in compliance with the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software distributed under
  11. * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  12. * ANY KIND, either express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #import "GooglePlacesDemos/DemoAppDelegate.h"
  16. #import <GooglePlaces/GooglePlaces.h>
  17. #import "GooglePlacesDemos/DemoData.h"
  18. #import "GooglePlacesDemos/DemoListViewController.h"
  19. #import "GooglePlacesDemos/SDKDemoAPIKey.h"
  20. @implementation DemoAppDelegate
  21. - (BOOL)application:(UIApplication *)application
  22. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  23. NSLog(@"Build version: %s", __VERSION__);
  24. // Do a quick check to see if you've provided an API key, in a real app you wouldn't need this but
  25. // for the demo it means we can provide a better error message.
  26. if (!kAPIKey.length) {
  27. // Blow up if APIKeys have not yet been set.
  28. NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier];
  29. NSString *format = @"Configure APIKeys inside SDKDemoAPIKey.h for your bundle `%@`, see "
  30. @"README.GooglePlacesDemos for more information";
  31. @throw [NSException exceptionWithName:@"DemoAppDelegate"
  32. reason:[NSString stringWithFormat:format, bundleId]
  33. userInfo:nil];
  34. }
  35. // Provide the Places SDK with your API key.
  36. [GMSPlacesClient provideAPIKey:kAPIKey];
  37. // Log the required open source licenses! Yes, just NSLog-ing them is not enough but is good for
  38. // a demo.
  39. NSLog(@"Google Places open source licenses:\n%@", [GMSPlacesClient openSourceLicenseInfo]);
  40. // Manually create a window. If you are using a storyboard in your own app you can ignore the rest
  41. // of this method.
  42. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  43. // Create our view controller with the list of demos.
  44. DemoData *demoData = [[DemoData alloc] init];
  45. DemoListViewController *masterViewController =
  46. [[DemoListViewController alloc] initWithDemoData:demoData];
  47. UINavigationController *masterNavigationController =
  48. [[UINavigationController alloc] initWithRootViewController:masterViewController];
  49. self.window.rootViewController = masterNavigationController;
  50. [self.window makeKeyAndVisible];
  51. return YES;
  52. }
  53. @end