The push notification is not showing on my physical android 9.0 device running via USB-debugging mode on android studio.
The publish-id is showing up using curl command but the notification is not showing up on my tray
我尝试了几次,甚至添加了新的Beam实例,但是在我的物理android 9.0上没有收到通知
我在bash中尝试了以下命令来手动获取推送通知:
curl -H“内容类型:application / json” -H“授权:Bearer 506FDD6A6B85E8105A1965B12CE43C55B1585465E56C00FB6
002836EEA24679C“ -X POST” https://58d01970-5780-4ad5-8431-edf38ec99369.pushnotifications.pusher.com/publish_api/v1/ins
tances / 58d01970-5780-4ad5-8431-edf38ec99369 /发表“
-d'{“ interests”:[“ hello”],“ fcm”:{“ notification”:{“ title”:“ Hell
o“,” body“:”你好,世界!“}}}'
android app level build.gradle
//firebase real time database
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-database:16.1.0'
//firebase authentiction
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-auth:16.2.1'
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
//pusher
implementation 'com.pusher:push-notifications-android:1.4.0'
implementation 'com.pusher:pusher-java-client:1.5.0'
android project level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android code:
import android.util.Log;
import com.pusher.client.PusherOptions;
import com.pusher.pushnotifications.PushNotifications;
import com.pusher.client.Pusher;
import com.pusher.client.channel.Channel;
import com.pusher.client.channel.SubscriptionEventListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
relativeLayout1=(RelativeLayout) findViewById(R.id.rellay1);
relativeLayout2=(RelativeLayout)findViewById(R.id.rellay2);
etUserName=(EditText) findViewById(R.id.etUserName);
etPassword=(EditText) findViewById(R.id.etPassword);
btn_Login=(Button) findViewById(R.id.btn_Login);
btn_SignUp=(Button) findViewById(R.id.btn_SignUp);
PushNotifications.start(getApplicationContext(), "58d01970-5780-4ad5-8431-edf38ec99369");
PushNotifications.addDeviceInterest("debug-hello");
Set<String> interests = PushNotifications.getDeviceInterests();
Log.i("interests",interests+"");
}
}