大家好,我正在开发一个使用 Firebase 云消息传递的应用程序。但是我有这样的情况,我不想让用户看到何时收到带有数据消息的通知。我已经通过从 myFirebaseMessagingService 中删除函数 sendNotification 解决了这个问题,但这仅在我的应用程序处于前台时才有效。我的问题是:当应用程序在后台并且通知来到系统托盘时,如何设置代码以便不显示通知图标?
这是我的主要活动:
public class MainActivity extends AppCompatActivity {
Button dugme, dugme2, dugmeBaza, dugmeToken;
DataBaseHelper db;
Cursor c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("onCreate", "ONCREATE");
db=new DataBaseHelper(this);
final Intent intent=getIntent();
setContentView(R.layout.activity_main);
String msg = getIntent().getStringExtra("click_action");
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (msg != null)
{
Log.d("MSG", msg);
if (msg.equals("goToFragment1")) {
Fragment1 fragment1 = new Fragment1();
fragmentTransaction.replace(R.id.myFragment, fragment1);
Log.d("FragmentTransaction", "Fragment je promenjen u onCreate!");
fragmentTransaction.commit();
Log.d("Create", "Kraj onCreatea");
}
}
dugme …Run Code Online (Sandbox Code Playgroud) 我想使用 Firebase 通知服务获取通知消息。我正在从 Firebase 发送消息,没关系。
如果用户运行,我想收到此通知,MainActivity我也想使用对话框显示弹出窗口。
如果用户运行其他活动,例如SettingActivity或ProfileActivity,通知处理无论如何,用户运行MainActivity弹出窗口突然出现。
为此,我使用 Greenbot Eventbus。当我在里面MainActivity并且通知来时它出现所以它可以。但是当我在里面时,另一个Activity通知没有来。
如何处理这个消息直到来MainActivity?
public class NotificationService extends FirebaseMessagingService {
private static final String TAG = "evenBus" ;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d(TAG, "onMessageReceived");
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
// do nothing if Notification message is received
Log.d(TAG, "Message data payload: " + remoteMessage.getNotification().getBody());
String body = remoteMessage.getNotification().getBody(); …Run Code Online (Sandbox Code Playgroud) notifications android firebase greenrobot-eventbus firebase-notifications
我正在使用 Node.js 的 Admin SDK 来发送推送通知。按照教程并使用此链接给出的类似示例初始化了多个项目。
我需要知道如何使用 node.js 向两个项目发送推送通知。使用以下方法发送通知,两个项目基于其与默认项目的工作,但另一个项目出现如下错误
exports.send_test_mailer = function(req, res) {
// Default project
var registrationToken = ["f-vRsDouUFQ:APA91bGktVzu3WjKGqeXqdiYPI8B0lQXs34TkJS4p7LaMiFGfp5LdfB1ZjEhO3CY5ci92apqgt1hEJY0ml11C4hxYUaPfDl7PeDHhcmDGur0JUx5l3M2mLEj30epwRBWVsE4xMSTls4f"];
var payload = {
notification: {
title: "driver app",
body: "driver app push notfications on the day."
},
data: {
score: "850",
time: "2:45"
}
};
firebaseAdmin.messaging().sendToDevice(registrationToken, payload)
.then(function(response) {
console.log("Successfully sent message driver:", JSON.stringify(response));
})
.catch(function(error) {
console.log("Error sending message driver:", JSON.stringify(error));
});
// Second project
var registrationTokens = ["dzXRXUMIB5w:APA91bHSArtroO8M33IHxaslQTugTcEzJcfkbsXEhwbXbvVzBws-aqG4aqKNr37j8WpZev7lolX7cFQlAKYZ1QV_EgC6zTGeT41n3lvSpcDyBg6t4SZZaoPe7nUO9sbdcXA2KDguxAbk"];
var payloads = {
notification: { …Run Code Online (Sandbox Code Playgroud) push-notification node.js firebase firebase-cloud-messaging firebase-notifications
我正在使用 firebase 开发一个 android 应用程序,这个应用程序应该每天推送两次通知,用户应该在应用程序设置中设置。
我看到至少 2 年前有人问过类似的问题,但没有答案,也许现在有一个选项可以做到。
无论如何我可以使用 Firebase 实现这一目标吗?如果没有,我该如何实现?
android android-notifications firebase firebase-cloud-messaging firebase-notifications
如果单击通知,我想打开特定页面。如何在 React Native 中做到这一点?
this.notificationListener = firebase.notifications().onNotification((notification: Notification) => {
this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification: Notification) => {
// Process your notification as required
// ANDROID: Remote notifications do not contain the channel ID.
// You will have to specify this manually if you'd like to re-display the notification.
const { title, body } = notification; }
);
const { title, body } = notification;
});
Run Code Online (Sandbox Code Playgroud) 新的Firebase通知服务允许我们使用控制台用户界面向所有移动应用用户发布通知.
但我找不到Firebase Notifications Service的任何REST API.我想根据事件通过服务器端代码自动向移动用户发送通知.Firebase Notifications Service是否具有可通过HTTP/S访问的API?
android ios firebase firebase-cloud-messaging firebase-notifications
这是我的代码
private void showNotification(String message) {
NotificationCompat.BigTextStyle stil = new NotificationCompat.BigTextStyle();
stil.setBigContentTitle("Ba??l");
stil.bigText(message);
Intent i=new Intent(this,Bilgi.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent=PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setAutoCancel(true);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setTicker("selam dost.mesaj geldi");
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setContentIntent(pendingIntent);
builder.setContentTitle("Bildirim");
builder.setContentText(message);
builder.setStyle(stil);
NotificationManager notificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0,builder.build());
}
Run Code Online (Sandbox Code Playgroud)
当我发送通知时(如果应用程序正在工作(图片的左侧)),我的通知不会显示.当应用程序在后台工作时,我的通知显示.我怎么解决这个问题 ?非常感谢你的帮助.
android firebase firebase-cloud-messaging firebase-notifications
我是Firebase的新手,我想实现FCM以从Firebase控制台发送通知。我FirebaseMessagingService在应用程序中创建的,我唯一的问题是FirebaseMessagingService设备重启后还能生存吗?如果设备重新启动然后云发出通知消息怎么办?
android firebase firebase-cloud-messaging firebase-notifications
我有一个iOS和Android应用程序,我可以从firebase控制台发送推送通知.我在分析部分创建了一个受众群体.现在,如果我创建推送消息,我想我应该能够在推送消息的目标部分中选择那些受众.但当然我不能,我只看到两个默认观众"购买者"和"所有用户".我错过了什么?
我已经使用AndroidHive中的 Firebase云消息传递FCM实现了Android推送通知,但是当应用程序处于后台时通知没有响起.
任何人都可以帮我在firebase后台通知上设置声音吗?
android push-notification firebase firebase-cloud-messaging firebase-notifications