我写了下面的方法来显示我的Android 5.1设备上的FCM通知.当我在FirebaseMessagingService中运行代码时,它只是提供单行通知,如果我在Activity中运行相同的代码,则会发出可扩展通知.
我基本上需要我的长FCM文本通知来扩展通知而不是显示部分通知文本.
任何线索?
private void showNotif(String messageBody){
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
// Constructs the Builder object.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.app_name))
.setContentText(messageBody)
.setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
.setAutoCancel(true)
.setContentIntent(pendingIntent)
/*
* Sets the big view "big text" style and supplies the
* text (the user's reminder message) that will be displayed
* in the detail area of the expanded notification.
* These calls are ignored by the …Run Code Online (Sandbox Code Playgroud) android android-notifications firebase firebase-notifications
我使用Firebase Auth和Messaging创建了一个应用程序,我一直通过Firebase控制台向应用程序发送通知,问题是我无法扩展通知,如果它很大.我该怎么做?帮我
public class FirebaseNots extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// [START_EXCLUDE]
// There are two types of messages data messages and notification messages. Data messages are handled
// here in onMessageReceived whether the app is in the foreground or background. Data messages are the …Run Code Online (Sandbox Code Playgroud) android android-notifications firebase firebase-cloud-messaging firebase-notifications
我想根据上一次触发事件在Firebase中定义一个受众群体。例如,我想重新吸引过去30天未打开应用程序的用户(事件:app_open)。
我一直试图根据此标准定义受众,但没有成功。
任何帮助,将不胜感激
我是 Firebase 云消息的新手。我构建了一个 IOS 应用程序来接收推送通知。该应用程序运行良好。我从 Firebase 控制台发送消息,并且它们显示正确。
现在我正在尝试构建一个 Web api 以允许我的客户发送推送消息(无需访问 firebase 控制台)。研究这里的文档我意识到我总是有一个“to”,意思是组、主题或设备 ID。
我的问题是:我可以向所有设备发送消息(就像我可以在控制台中执行的那样)吗?我是啊,怎么会这样呢?
提前致谢!
ios firebase firebase-cloud-messaging firebase-notifications
我正在开发一个iOS应用程序,它应该接收从Firebase控制台发送的推送通知.我正在使用Swift 3和iOS 10.
根据Firebase文档的建议,在我们的应用程序完成启动之前,我们必须将我们的委托对象分配给UNUserNotificationCenter对象以接收和显示通知,以及FIRMessaging接收数据消息的对象.
这已经在该didFinishLaunchingWithOptions方法中完成.我按照所有步骤来配置Firmessaging以及APN.
现在,当我从Firebase控制台发送消息时,我通过applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage)方法接收消息.
问题是我无法从remoteMessage.appData字典中提取消息的正文.知道身体在内remoteMessage.appData["notification"].的确,指示
print(remoteMessage.appData)
Run Code Online (Sandbox Code Playgroud)
版画
[AnyHashable("notification"): {
body = Hello Notifications;
e = 1;
}, AnyHashable("from"): 49679924394, AnyHashable("collapse_key"): com.company.app]
Run Code Online (Sandbox Code Playgroud)
印花
remoteMessage.appData["notification"]
Run Code Online (Sandbox Code Playgroud)
节目
{
body = Hello Notifications;
e = 1;
}
Run Code Online (Sandbox Code Playgroud)
我试过了
remoteMessage.appData["notification"]["body"]
Run Code Online (Sandbox Code Playgroud)
和
remoteMessage.appData["notification"].body
Run Code Online (Sandbox Code Playgroud)
但它会导致语法错误.我无法提取身体以便在警报控制器中显示它.appDelegate的代码如下.
class AppDelegate: UIResponder, UIApplicationDelegate, FIRMessagingDelegate, UNUserNotificationCenterDelegate{
......
func application(_ application: UIApplication, didFinishLaunchingWithOptions, launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
application.isStatusBarHidden = true
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
if …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮我发送这样的通知:
我正在使用Firebase通知.我发送通知时,我尝试将图片网址设置为高级选项和键1的值.图像URL显示在调试器中,但当我的设备中出现通知时,不会显示图像.
这是我的代码.
import UIKit
import UserNotifications
import Firebase
import FirebaseInstanceID
import FirebaseMessaging
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let gcmMessageIDKey = "gcm.message_id"
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Register for remote notifications. This shows a permission dialog on first run, to
// show the dialog at a more appropriate time move this registration accordingly.
// [START register_for_notifications]
if #available(iOS 10.0, *) {
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization( …Run Code Online (Sandbox Code Playgroud) ios firebase swift3 firebase-cloud-messaging firebase-notifications
我在我的应用中使用了Google Analytics(分析),而且工作正常.但是,如果我每天有100个活跃用户,然后我发送通知,则我将1000个连接用户的峰值计为"活动".
我不知道是否有一种简单的方法可以防止这些用户被视为活动用户.他们中的大多数人不会打开通知,我不希望他们算作活动.我想只计算打开应用程序的用户,而不是所有收到通知的用户.
我在发送的通知中使用"body"字段,并在应用程序中创建自定义通知.
是否可以删除这些"活跃"用户?
非常感谢你!
我正在尝试在我的iOS应用程序中使用Firebase.我成功地将其集成并接收来自所有3个目标(用户段,主题和单个设备)的通知.我的问题是如何知道从哪个主题收到特定通知?
编辑:
我正在测试iOS11.2(XCode9.2)和我的响应(userInfo)是:
{
aps = {
alert = test;
sound = default;
};
"gcm.message_id" = "0:1513282329413512%38894e8e28894e8e";
"gcm.n.e" = 1;
"gcm.notification.sound2" = default;
"google.c.a.c_id" = 1542306492273623048;
"google.c.a.c_l" = test;
"google.c.a.e" = 1;
"google.c.a.ts" = 1513182256;
"google.c.a.udt" = 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到了,gcm.message_id但看起来"gcm.message_id" = "0:1512894251264950%38894e8e38894e8e"; 如何将此映射到我的主题名称?
谢谢.
apple-push-notifications ios firebase firebase-notifications
我使用 React Native Firebase 在 React Native 中接收通知。当在后台收到消息并单击通知时,将触发 getInitialNotification。如果我导航到另一个屏幕而不是回到我的 HomeActivity,getInitialNotification 将再次被触发。我怎样才能实现只触发一次?
import React, { Component } from 'react';
import { StyleSheet, Platform, View, Text, YellowBox, Button } from 'react-native';
import StyleIndex from './css/StyleIndex';
import firebase from 'react-native-firebase';
import type { Notification, NotificationOpen } from 'react-native-firebase';
export default class HomeActivity extends Component {
state = { currentUser: null }
componentDidMount() {
const { currentUser } = firebase.auth()
this.setState({ currentUser })
var collectionReference = firebase.firestore().collection('users');
var query = collectionReference.where("phone", "==", currentUser.phoneNumber);
// …Run Code Online (Sandbox Code Playgroud) javascript firebase react-native firebase-cloud-messaging firebase-notifications
如何添加操作按钮来推送这样的通知:
我试过这个,但它不起作用:
=> https://firebase.googleblog.com/2018/05/web-notifications-api-support-now.html
这是我的通知负载:
array
(
"title" => "FCM Message",
"body" => "This is an FCM Message",
"click_action" => "http://example.com/",
"icon" => "/logo.jpg",
"actions" => array(
0 => array(
'title' => 'Like',
'click_action' => 'http://example.com/?aaa=1',
'icon' => 'icons/heart.png',
),
1 => array(
'title' => 'Unsubscribe',
'click_action' => 'http://example.com/?aaa=2',
'icon' => 'icons/cross.png',
),
),
);
Run Code Online (Sandbox Code Playgroud)
我尝试使用消息有效负载也不起作用:
$msg = array
(
"webpush" => array
(
"notification" => array
(
"title" => "Fish Photos ",
"body" => "Thanks for signing up for …Run Code Online (Sandbox Code Playgroud)