From 905e5617fd2c73f0b1250b8e29752bfd31717281 Mon Sep 17 00:00:00 2001 From: Nikita Lutsenko Date: Wed, 6 Jul 2016 20:55:25 -0700 Subject: [PATCH] Update starter projects to use configuration-based initialization API. --- .../ParseOSXStarterProject/AppDelegate.swift | 22 ++++++++++----- .../ParseOSXStarterProject/AppDelegate.m | 22 ++++++++++----- .../ParseStarterProject/AppDelegate.swift | 24 ++++++++++++----- .../ParseStarterProjectAppDelegate.m | 24 ++++++++++++----- .../ParseStarter/AppDelegate.swift | 16 ++++++++--- .../ExtensionDelegate.swift | 24 ++++++++++++----- .../ParseStarterProject/AppDelegate.swift | 27 +++++++++++-------- 7 files changed, 114 insertions(+), 45 deletions(-) diff --git a/ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject/AppDelegate.swift b/ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject/AppDelegate.swift index 99eedac37..c2c5b237a 100644 --- a/ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject/AppDelegate.swift +++ b/ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject/AppDelegate.swift @@ -17,15 +17,25 @@ class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow? func applicationDidFinishLaunching(aNotification: NSNotification) { - // Enable storing and querying data from Local Datastore. - // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. - Parse.enableLocalDatastore() - // **************************************************************************** - // Uncomment and fill in with your Parse credentials: - // Parse.setApplicationId("your_application_id", clientKey: "your_client_key") + // Initialize Parse SDK // **************************************************************************** + let configuration = ParseClientConfiguration { + // Add your Parse applicationId: + $0.applicationId = "your_application_id" + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + $0.clientKey = "your_client_key" + + // Uncomment the following line and change to your Parse Server address; + $0.server = "https://YOUR_PARSE_SERVER/parse" + + // Enable storing and querying data from Local Datastore. + // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. + $0.localDatastoreEnabled = true + } + Parse.initializeWithConfiguration(configuration) + PFUser.enableAutomaticUser() let defaultACL: PFACL = PFACL() diff --git a/ParseStarterProject/OSX/ParseOSXStarterProject/ParseOSXStarterProject/AppDelegate.m b/ParseStarterProject/OSX/ParseOSXStarterProject/ParseOSXStarterProject/AppDelegate.m index 8af866b08..497b40d7c 100644 --- a/ParseStarterProject/OSX/ParseOSXStarterProject/ParseOSXStarterProject/AppDelegate.m +++ b/ParseStarterProject/OSX/ParseOSXStarterProject/ParseOSXStarterProject/AppDelegate.m @@ -17,15 +17,25 @@ @implementation AppDelegate #pragma mark NSApplicationDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { - // Enable storing and querying data from Local Datastore. - // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. - [Parse enableLocalDatastore]; - // **************************************************************************** - // Uncomment and fill in with your Parse credentials: - // [Parse setApplicationId:@"your_application_id" clientKey:@"your_client_key"]; + // Initialize Parse SDK // **************************************************************************** + [Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id _Nonnull configuration) { + // Add your Parse applicationId: + configuration.applicationId = @"your_application_id"; + + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + // configuration.clientKey = @"your_client_key"; + + // Uncomment the following line and change to your Parse Server address; + // configuration.server = @"https://YOUR_PARSE_SERVER/parse"; + + // Enable storing and querying data from Local Datastore. Remove this line if you don't want to + // use Local Datastore features or want to use cachePolicy. + configuration.localDatastoreEnabled = YES; + }]]; + [PFUser enableAutomaticUser]; PFACL *defaultACL = [PFACL ACL]; diff --git a/ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift b/ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift index 8c88242da..a9ac6669e 100644 --- a/ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift +++ b/ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift @@ -24,14 +24,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate { //-------------------------------------- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Enable storing and querying data from Local Datastore. - // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. - Parse.enableLocalDatastore() + // **************************************************************************** + // Initialize Parse SDK + // **************************************************************************** + + let configuration = ParseClientConfiguration { + // Add your Parse applicationId: + $0.applicationId = "your_application_id" + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + $0.clientKey = "your_client_key" + + // Uncomment the following line and change to your Parse Server address; + $0.server = "https://YOUR_PARSE_SERVER/parse" + + // Enable storing and querying data from Local Datastore. + // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. + $0.localDatastoreEnabled = true + } + Parse.initializeWithConfiguration(configuration) // **************************************************************************** - // Uncomment and fill in with your Parse credentials: - // Parse.setApplicationId("your_application_id", clientKey: "your_client_key") - // // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/ // Uncomment the line inside ParseStartProject-Bridging-Header and the following line here: diff --git a/ParseStarterProject/iOS/ParseStarterProject/ParseStarterProject/ParseStarterProjectAppDelegate.m b/ParseStarterProject/iOS/ParseStarterProject/ParseStarterProject/ParseStarterProjectAppDelegate.m index 9f46da12b..adc76983e 100644 --- a/ParseStarterProject/iOS/ParseStarterProject/ParseStarterProject/ParseStarterProjectAppDelegate.m +++ b/ParseStarterProject/iOS/ParseStarterProject/ParseStarterProject/ParseStarterProjectAppDelegate.m @@ -24,14 +24,26 @@ @implementation ParseStarterProjectAppDelegate #pragma mark UIApplicationDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Enable storing and querying data from Local Datastore. Remove this line if you don't want to - // use Local Datastore features or want to use cachePolicy. - [Parse enableLocalDatastore]; + // **************************************************************************** + // Initialize Parse SDK + // **************************************************************************** + + [Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id _Nonnull configuration) { + // Add your Parse applicationId: + configuration.applicationId = @"your_application_id"; + + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + // configuration.clientKey = @"your_client_key"; + + // Uncomment the following line and change to your Parse Server address; + // configuration.server = @"https://YOUR_PARSE_SERVER/parse"; + + // Enable storing and querying data from Local Datastore. Remove this line if you don't want to + // use Local Datastore features or want to use cachePolicy. + configuration.localDatastoreEnabled = YES; + }]]; // **************************************************************************** - // Uncomment and fill in with your Parse credentials: - // [Parse setApplicationId:@"your_application_id" clientKey:@"your_client_key"]; - // // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/ // [PFFacebookUtils initializeFacebook]; diff --git a/ParseStarterProject/tvOS/ParseStarterProject-Swift/ParseStarter/AppDelegate.swift b/ParseStarterProject/tvOS/ParseStarterProject-Swift/ParseStarter/AppDelegate.swift index 6b3cf12ec..43382d048 100644 --- a/ParseStarterProject/tvOS/ParseStarterProject-Swift/ParseStarter/AppDelegate.swift +++ b/ParseStarterProject/tvOS/ParseStarterProject-Swift/ParseStarter/AppDelegate.swift @@ -22,12 +22,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // **************************************************************************** - // - // Uncomment and fill in with your Parse credentials: - // Parse.setApplicationId("your_application_id", clientKey: "your_client_key") - // + // Initialize Parse SDK // **************************************************************************** + let configuration = ParseClientConfiguration { + // Add your Parse applicationId: + $0.applicationId = "your_application_id" + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + $0.clientKey = "your_client_key" + + // Uncomment the following line and change to your Parse Server address; + $0.server = "https://YOUR_PARSE_SERVER/parse" + } + Parse.initializeWithConfiguration(configuration) + PFUser.enableAutomaticUser() let defaultACL = PFACL() diff --git a/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarter Extension/ExtensionDelegate.swift b/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarter Extension/ExtensionDelegate.swift index 6499e3961..be4e04124 100644 --- a/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarter Extension/ExtensionDelegate.swift +++ b/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarter Extension/ExtensionDelegate.swift @@ -13,12 +13,24 @@ import Parse class ExtensionDelegate: NSObject, WKExtensionDelegate { func applicationDidFinishLaunching() { - // Enable storing and querying data from Local Datastore. - // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. - Parse.enableLocalDatastore() - - // Make sure to replace with your Parse app credentials: - Parse.setApplicationId("your_application_id", clientKey: "your_client_key") + // **************************************************************************** + // Initialize Parse SDK + // **************************************************************************** + + let configuration = ParseClientConfiguration { + // Add your Parse applicationId: + $0.applicationId = "your_application_id" + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + $0.clientKey = "your_client_key" + + // Uncomment the following line and change to your Parse Server address; + $0.server = "https://YOUR_PARSE_SERVER/parse" + + // Enable storing and querying data from Local Datastore. + // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. + $0.localDatastoreEnabled = true + } + Parse.initializeWithConfiguration(configuration) // Track application opened event in Analytics PFAnalytics.trackAppOpenedWithLaunchOptions(nil) diff --git a/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift b/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift index 44beca167..049e91d35 100644 --- a/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift +++ b/ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift @@ -24,20 +24,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate { //-------------------------------------- func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Enable storing and querying data from Local Datastore. - // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. - Parse.enableLocalDatastore() - // **************************************************************************** - // Uncomment and fill in with your Parse credentials: - // Parse.setApplicationId("your_application_id", clientKey: "your_client_key") - // - // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as - // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/ - // Uncomment the line inside ParseStartProject-Bridging-Header and the following line here: - // PFFacebookUtils.initializeFacebook() + // Initialize Parse SDK // **************************************************************************** + let configuration = ParseClientConfiguration { + // Add your Parse applicationId: + $0.applicationId = "your_application_id" + // Uncomment and add your clientKey (it's not required if you are using Parse Server): + $0.clientKey = "your_client_key" + + // Uncomment the following line and change to your Parse Server address; + $0.server = "https://YOUR_PARSE_SERVER/parse" + + // Enable storing and querying data from Local Datastore. + // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy. + $0.localDatastoreEnabled = true + } + Parse.initializeWithConfiguration(configuration) + PFUser.enableAutomaticUser() let defaultACL = PFACL()