forked from parse-community/ParseUI-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppDelegate.m
More file actions
125 lines (103 loc) · 4.75 KB
/
Copy pathAppDelegate.m
File metadata and controls
125 lines (103 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Copyright (c) 2014, Parse, LLC. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Parse.
*
* As with any software that integrates with the Parse platform, your use of
* this software is subject to the Parse Terms of Service
* [https://www.parse.com/about/terms]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import <ParseTwitterUtils/ParseTwitterUtils.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKApplicationDelegate.h>
#import "PFUIDemoViewController.h"
@implementation AppDelegate
#pragma mark -
#pragma mark UIApplicationDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Parse setApplicationId:@"UdNpOP2XFoEiXLZEBDl6xONmCMH8VjETmnEsl0xJ"
clientKey:@"wNJFho0fQaQFQ2Fe1x9b67lVBakJiAtFj1Uz30A9"];
[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];
[PFTwitterUtils initializeWithConsumerKey:@"3Q9hMEKqqSg4ie2pibZ2sVJuv"
consumerSecret:@"IEZ9wv2d1EpXNGFKGp7sAGdxRtyqtPwygyciFZwTHTGhPp4FMj"];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[PFUIDemoViewController alloc] init]];
[self.window makeKeyAndVisible];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self _setupTestData];
});
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
#pragma mark -
#pragma mark Test Data
- (void)_setupTestData {
NSArray *todoTitles = @[ @"Build Parse",
@"Make everything awesome",
@"Go out for the longest run",
@"Do more stuff",
@"Conquer the world",
@"Build a house",
@"Grow a tree",
@"Be awesome",
@"Setup an app",
@"Do stuff",
@"Buy groceries",
@"Wash clothes" ];
NSMutableArray *objects = [NSMutableArray array];
PFQuery *query = [PFQuery queryWithClassName:@"Todo"];
NSArray *todos = [query findObjects];
if ([todos count] == 0) {
int count = 0;
for (NSString *title in todoTitles) {
int priority = count % 3;
PFObject *todo = [[PFObject alloc] initWithClassName:@"Todo"];
todo[@"title"] = title;
todo[@"priority"] = @(priority);
[objects addObject:todo];
count++;
}
}
NSArray *appNames = @[ @"Anypic",
@"Anywall",
@"f8" ];
PFQuery *appsQuery = [PFQuery queryWithClassName:@"App"];
NSArray *apps = [appsQuery findObjects];
if ([apps count] == 0) {
for (NSUInteger i = 0; i < 3; i++) {
NSString *name = [NSString stringWithFormat:@"%d", (int)i];
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"png"];
NSData *data = [NSData dataWithContentsOfFile:path];
PFFile *file = [PFFile fileWithName:[path lastPathComponent] data:data];
PFObject *object = [[PFObject alloc] initWithClassName:@"App"];
object[@"icon"] = file;
object[@"name"] = appNames[i];
[objects addObject:object];
}
}
if ([objects count] != 0) {
[PFObject saveAll:objects];
}
}
@end