Skip to content

Commit

Permalink
gcm推送及融云自带推送
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric0x committed Nov 7, 2017
1 parent 1460416 commit 1e00507
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
46 changes: 43 additions & 3 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,52 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />



<!-- GCM 配置开始 < -->
<permission
android:name="com.lomocoin.lomocoin.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.lomocoin.lomocoin.permission.C2D_MESSAGE" />
<!-- GCM 配置结束 < -->

<application>

<receiver
android:exported="true"
android:name="com.lomocoin.imlib.RongNotificationReceiver">
<intent-filter>
<action android:name="io.rong.push.intent.MESSAGE_ARRIVED" />
<action android:name="io.rong.push.intent.MI_MESSAGE_ARRIVED" />
<action android:name="io.rong.push.intent.MESSAGE_CLICKED" />
<action android:name="io.rong.push.intent.MI_MESSAGE_CLICKED" />
</intent-filter>
</receiver>


<!-- GCM 配置 < -->
<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.lomocoin.lomocoin" />
<!-- 替换为自己的packagename < -->
</intent-filter>
</receiver>

<service android:name="io.rong.push.platform.RongGcmListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service android:name="io.rong.push.platform.RongGCMInstanceIDListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<!-- GCM 配置结束 < -->


<!-- imlib config begin -->
<meta-data
android:name="RONG_CLOUD_APP_KEY"
android:value="3argexb630sfe" />

<service
android:name="io.rong.imlib.ipc.RongService"
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ android {
}

dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.facebook.react:react-native:+'
compile files('libs/Rong_IMLib.jar')
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import io.rong.message.RichContentMessage;
import io.rong.message.TextMessage;
import io.rong.message.VoiceMessage;
import io.rong.push.RongPushClient;
import io.rong.push.common.RongException;

/**
* 融云原生功能模块
Expand Down Expand Up @@ -100,6 +102,11 @@ public String getName() {
@ReactMethod
public void initWithAppKey(String appKey) {
Log.e("isme", "rong init appkey:" + appKey);
try {
RongPushClient.registerGCM(context);
} catch (RongException e) {
e.printStackTrace();
}
RongIMClient.init(context, appKey);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.lomocoin.imlib;

import android.content.Context;
import android.util.Log;

import io.rong.push.notification.PushMessageReceiver;
import io.rong.push.notification.PushNotificationMessage;

/**
* Created by qiaojiayan on 17/10/31.
*/

public class RongNotificationReceiver extends PushMessageReceiver {
@Override
public boolean onNotificationMessageArrived(Context context, PushNotificationMessage pushNotificationMessage) {
Log.e("isme","rong msg init");
return false;
}

@Override
public boolean onNotificationMessageClicked(Context context, PushNotificationMessage pushNotificationMessage) {
return false;
}
}

0 comments on commit 1e00507

Please sign in to comment.