Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
Fix git ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Apr 8, 2019
1 parent e9b398a commit 54b4ac2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -6,7 +6,7 @@ build/
lib/js/
node_modules/
xcuserdata/
IMLib/
ios/IMLib/

*.iml
.classpath
Expand Down
@@ -0,0 +1,50 @@
package cn.rongcloud.imlib.react;

import android.content.Context;
import android.net.Uri;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
import io.rong.push.PushType;
import io.rong.push.notification.PushMessageReceiver;
import io.rong.push.notification.PushNotificationMessage;

public class RCPushReceiver extends PushMessageReceiver {
static RCTDeviceEventEmitter eventEmitter;

private WritableMap messageToMap(PushNotificationMessage message, PushType pushType) {
WritableMap map = Arguments.createMap();
Uri portrait = message.getSenderPortrait();
map.putString("pushType", pushType.getName());
map.putString("pushId", message.getPushId());
map.putString("pushTitle", message.getPushTitle());
map.putString("pushFlag", message.getPushFlag());
map.putString("pushContent", message.getPushContent());
map.putString("pushData", message.getPushData());
map.putString("objectName", message.getObjectName());
map.putString("senderId", message.getSenderId());
map.putString("senderName", message.getSenderName());
map.putString("senderPortraitUrl", portrait == null ? "" : portrait.toString());
map.putString("targetId", message.getTargetId());
map.putString("targetUserName", message.getTargetUserName());
map.putInt("conversationType", message.getConversationType().getValue());
map.putString("extra", message.getExtra());
return map;
}

@Override
public boolean onNotificationMessageArrived(Context context, PushType pushType, PushNotificationMessage message) {
if (eventEmitter != null) {
eventEmitter.emit("rcimlib-push-arrived", messageToMap(message, pushType));
}
return false;
}

@Override
public boolean onNotificationMessageClicked(Context context, PushType pushType, PushNotificationMessage message) {
if (eventEmitter != null) {
eventEmitter.emit("rcimlib-push-clicked", messageToMap(message, pushType));
}
return false;
}
}

0 comments on commit 54b4ac2

Please sign in to comment.