-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathAppDelegate+Firestack.m
More file actions
94 lines (80 loc) · 3.11 KB
/
Copy pathAppDelegate+Firestack.m
File metadata and controls
94 lines (80 loc) · 3.11 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
#import <objc/runtime.h>
#import "AppDelegate+Firestack.h"
#import "Firebase.h"
#import "Firestack.h"
#import "FirestackEvents.h"
@implementation AppDelegate (Firestack)
+ (void) load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
SEL originalSelector = @selector(application:didFinishLaunchingWithOptions:);
SEL swizzledSelector = @selector(swizzled_application:didFinishLaunchingWithOptions:);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
});
}
- (BOOL) swizzled_application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
BOOL res = [self swizzled_application:application didFinishLaunchingWithOptions:launchOptions];
[FIRApp configure];
[self setupListeners];
[self dispatchFirestackConfigured];
return res;
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void) setupListeners
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(firestackConfigured:)
name:kFirestackInitialized
object:nil];
// Add listener for when firestack the app reloads
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadFirestack)
name:RCTReloadNotification
object:nil];
}
- (void) dispatchFirestackConfigured
{
FIROptions *opts = [[FIRApp defaultApp] options];
NSLog(@"opts: %@", opts);
NSLog(@"googleAppID: %@", [opts googleAppID]);
NSLog(@"GCMSenderID: %@", [opts GCMSenderID]);
NSLog(@"APIKey: %@", [opts APIKey]);
NSLog(@"databaseURL: %@", [opts databaseURL]);
NSLog(@"trackingID: %@", [opts trackingID]);
NSLog(@"storageBucket: %@", [opts storageBucket]);
NSLog(@"clientID: %@", [opts clientID]);
NSLog(@"androidClientID: %@", [opts androidClientID]);
// Post notification that we've initialized Firebase
// [[NSNotificationCenter defaultCenter]
// postNotificationName:kFirestackInitialized
// object:nil];
}
- (void) reloadFirestack
{
// TODO:
}
- (void) firestackConfigured:(NSDictionary *) configuration
{
NSLog(@"firestackConfigured: %@", configuration);
}
@end