react-native-firestack icon indicating copy to clipboard operation
react-native-firestack copied to clipboard

[V3] ref.onDisconnect().setValue() allows only strings or objects

Open florianbepunkt opened this issue 9 years ago • 0 comments

ref.onDiscconnect().setValue() only allows for strings and objects…

this makes it difficult to implement a presence system (storing timestamp or a isOnline boolean).

I checked the iOS and android code and there are only methods for setting string and objects. I tried adding additional native methods to handle ints and bools but failed miserably

in iOS adding the following method

RCT_EXPORT_METHOD(onDisconnectSetNumber:(NSString *) path
                  val:(NSNumber *) val
                  callback:(RCTResponseSenderBlock) callback)
{
    FIRDatabaseReference *ref = [self getPathRef:path];
    [ref onDisconnectSetValue:val
          withCompletionBlock:^(NSError * _Nullable error, FIRDatabaseReference * _Nonnull ref) {
              [self handleCallback:@"onDisconnectSetNumber" callback:callback databaseError:error];
          }];
}

gives me a conversion error…

Implicit conversion of a non-Objective-C pointer type 'long *' to 'id _Nullable' is disallowed with ARC

any idea on how to fix this? I could add the methods for ints and bools in the native code and change the js part to check the type of value and call the right method accordingly.

florianbepunkt avatar Dec 11 '16 14:12 florianbepunkt