This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Jeepeng/develop
Release v0.7
- Loading branch information
Showing
13 changed files
with
1,793 additions
and
1,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 2 additions & 92 deletions
94
android/src/main/java/com/jeepeng/react/xgpush/receiver/HWMessageReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,11 @@ | ||
package com.jeepeng.react.xgpush.receiver; | ||
|
||
import android.app.NotificationManager; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
|
||
import com.huawei.hms.support.api.push.PushReceiver; | ||
import com.jeepeng.react.xgpush.Constants; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import com.tencent.android.hwpush.HWPushMessageReceiver; | ||
|
||
/** | ||
* 华为官方推送通道消息接收器 | ||
* Created by Jeepeng on 2018/3/11. | ||
*/ | ||
|
||
public class HWMessageReceiver extends PushReceiver { | ||
|
||
@Override | ||
public void onEvent(Context context, Event event, Bundle extras) { | ||
if (Event.NOTIFICATION_OPENED.equals(event) || Event.NOTIFICATION_CLICK_BTN.equals(event)) { | ||
int notifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0); | ||
if (0 != notifyId) { | ||
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||
manager.cancel(notifyId); | ||
} | ||
} | ||
|
||
String message = extras.getString(BOUND_KEY.pushMsgKey); | ||
String deviceToken = extras.getString(BOUND_KEY.deviceTokenKey); | ||
int receiveType = extras.getInt(BOUND_KEY.receiveTypeKey); | ||
String pushState = extras.getString(BOUND_KEY.pushStateKey); | ||
int pushNotifyId = extras.getInt(BOUND_KEY.pushNotifyId, 0); | ||
// message:[{"id":"123456"}] | ||
// Bundle[{receiveType=4, pushMsg=[{"id":"1"},{"name":"jeepeng"},{"sex":"man"}]}] | ||
|
||
if (Event.NOTIFICATION_OPENED.equals(event)) { | ||
// 通知在通知栏被点击啦。。。。。 | ||
Intent intent = new Intent(Constants.ACTION_ON_NOTIFICATION_CLICKED); | ||
Bundle bundle = new Bundle(); | ||
bundle.putString("content", message); | ||
intent.putExtra("notification", bundle); | ||
|
||
intent.putExtra("content", message); | ||
intent.putExtra("custom_content", message); | ||
context.sendBroadcast(intent); | ||
} | ||
|
||
super.onEvent(context, event, extras); | ||
} | ||
|
||
@Override | ||
public boolean onPushMsg(Context context, byte[] msg, Bundle bundle) { | ||
try { | ||
String content = new String(msg, "UTF-8"); | ||
Intent intent = new Intent(Constants.ACTION_ON_TEXT_MESSAGE); | ||
intent.putExtra("content", content); | ||
context.sendBroadcast(intent); | ||
System.out.println(bundle); | ||
Log.i("HWMessageReceiver", "收到PUSH透传消息,消息内容为:" + content); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return super.onPushMsg(context, msg, bundle); | ||
} | ||
|
||
@Override | ||
public void onPushState(Context context, boolean pushState) { | ||
super.onPushState(context, pushState); | ||
} | ||
|
||
@Override | ||
public void onToken(Context context, String token, Bundle extras) { | ||
super.onToken(context, token, extras); | ||
} | ||
|
||
@Override | ||
public void onToken(Context context, String token) { | ||
super.onToken(context, token); | ||
} | ||
|
||
private void writeToFile(String conrent) { | ||
String SDPATH = Environment.getExternalStorageDirectory() + "/huawei.txt"; | ||
try { | ||
FileWriter fileWriter = new FileWriter(SDPATH, true); | ||
|
||
fileWriter.write(conrent+"\r\n"); | ||
fileWriter.flush(); | ||
fileWriter.close(); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
|
||
public class HWMessageReceiver extends HWPushMessageReceiver { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Jan 17 12:01:37 CST 2018 | ||
#Tue Mar 27 17:51:16 CST 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.