Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Port fix from github to firebase_database plugin #39

Merged
merged 1 commit into from
May 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/firebase_database/ios/Classes/FirebaseDatabasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ @interface NSError (FlutterError)
@implementation NSError (FlutterError)
- (FlutterError *)flutterError {
return [FlutterError
errorWithCode:[NSString stringWithFormat:@"Error %d", self.code]
errorWithCode:[NSString stringWithFormat:@"Error %ld", self.code]
message:self.domain
details:self.localizedDescription];
}
Expand All @@ -24,6 +24,13 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
binaryMessenger:[registrar messenger]];
FirebaseDatabasePlugin *instance = [[FirebaseDatabasePlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
// TODO(jackson): stub code that should be replaced with dynamic registration.
[[[FIRDatabase database].reference queryLimitedToLast:10]
observeEventType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot *_Nonnull snapshot) {
[channel invokeMethod:@"DatabaseReference#childAdded"
arguments:@[ snapshot.key, snapshot.value ]];
}];
}

- (instancetype)init {
Expand All @@ -32,12 +39,6 @@ - (instancetype)init {
if (![FIRApp defaultApp]) {
[FIRApp configure];
}
[[[FIRDatabase database].reference queryLimitedToLast:10]
observeEventType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot *_Nonnull snapshot) {
[channel invokeMethod:@"DatabaseReference#childAdded"
arguments:@[ snapshot.key, snapshot.value ]];
}];
}
return self;
}
Expand Down