From 74576e8f63e4aa4a1336bd0e2ec750fd89f621aa Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Thu, 11 May 2017 11:58:46 -0700 Subject: [PATCH] Port fix from github to firebase_database plugin (#39) --- .../ios/Classes/FirebaseDatabasePlugin.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/firebase_database/ios/Classes/FirebaseDatabasePlugin.m b/packages/firebase_database/ios/Classes/FirebaseDatabasePlugin.m index b8d5b797629c..ce70dc3e526e 100755 --- a/packages/firebase_database/ios/Classes/FirebaseDatabasePlugin.m +++ b/packages/firebase_database/ios/Classes/FirebaseDatabasePlugin.m @@ -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]; } @@ -24,6 +24,13 @@ + (void)registerWithRegistrar:(NSObject *)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 { @@ -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; }