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

Commit

Permalink
Port fix from github to firebase_database plugin (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
collinjackson authored and goderbauer committed May 11, 2017
1 parent 153ac27 commit 74576e8
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit 74576e8

Please sign in to comment.