[ios, android] fixed messaging() send() - now a promise on native - added stub method for ios as the existing one was empty

This commit is contained in:
Salakar 2017-03-15 14:00:28 +00:00
parent cd4664fb68
commit 1acbff834f
3 changed files with 7 additions and 22 deletions

View File

@ -165,7 +165,7 @@ public class RNFirebaseMessaging extends ReactContextBaseJavaModule {
// String senderId, String messageId, String messageType,
@ReactMethod
public void send(ReadableMap params, final Callback callback) {
public void send(ReadableMap params, final Promise promise) {
ReadableMap data = params.getMap("data");
FirebaseMessaging fm = FirebaseMessaging.getInstance();
RemoteMessage.Builder remoteMessage = new RemoteMessage.Builder(params.getString("sender"));
@ -194,15 +194,10 @@ public class RNFirebaseMessaging extends ReactContextBaseJavaModule {
try {
fm.send(remoteMessage.build());
WritableMap res = Arguments.createMap();
res.putString("status", "success");
Log.d(TAG, "send: Message sent");
callback.invoke(null, res);
promise.resolve(null);
} catch (Exception e) {
Log.e(TAG, "send: error sending message", e);
WritableMap error = Arguments.createMap();
error.putString("code", e.toString());
error.putString("message", e.toString());
callback.invoke(error);
promise.reject("messaging/unknown", e.getMessage(), e);
}
}

View File

@ -217,20 +217,10 @@ RCT_EXPORT_METHOD(cancelLocalNotifications:(NSDictionary<NSString *, id> *)userI
}
}
RCT_EXPORT_METHOD(sendRemote:(UILocalNotification *)notification
callback:(RCTResponseSenderBlock) callback)
{
}
RCT_EXPORT_METHOD(send:(NSString *) senderId
messageId:(NSString *) messageId
messageType:(NSString *) messageType
msg: (NSString *) msg
callback:(RCTResponseSenderBlock)callback)
{
RCT_EXPORT_METHOD(send:(NSDictionary *) message resolver:(RCTPromiseResolveBlock) resolve rejecter:(RCTPromiseRejectBlock) reject){
// todo
resolve([NSNull null]);
}
RCT_EXPORT_METHOD(listenForTokenRefresh:(RCTResponseSenderBlock)callback)

View File

@ -49,7 +49,7 @@ export default class Messaging extends Base {
send(remoteMessage: RemoteMessage) {
if (!remoteMessage || !remoteMessage.data) return Promise.reject(new Error('Invalid remote message format provided.'));
return promisify('send', FirebaseMessaging)(remoteMessage);
return FirebaseMessaging.send(remoteMessage);
}
//