标签: firebase-cloud-messaging

如何使用FCM向特定用户发送通知?

我为FCM准备了接收器,可以向所有设备发送通知.

带有此链接的gcm-http.googleapis.com/gcm/send可以发送给已注册的目标用户并将其发布到目标设备,如下面的json:

 {
     "notification": {
                "title": "sample Title",
                "text": "sample text"   },   
        "to" : "[registration id]"
         }
Run Code Online (Sandbox Code Playgroud)

但是,我需要通过电子邮件或姓名等向我选择的目标用户发送通知.例如:

{
     "notification": {
                "title": "sample Title",
                "text": "sample text"   },   
        "to" : "[email or name or sex ...]"
         }
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?我是否需要创建Web服务器或其他东西?

notifications android firebase google-cloud-messaging firebase-cloud-messaging

23
推荐指数
1
解决办法
3万
查看次数

Firebase云消息传递API密钥

有哪些方法可以在Firebase控制台中重新生成FCM的API密钥(云消息传递部分)?密钥不可编辑,与Google API控制台中自动生成的密钥不同.由于这种错误配置,我总是从FCM 获得未经授权的401 ...

android firebase google-cloud-messaging firebase-cloud-messaging

23
推荐指数
3
解决办法
2万
查看次数

从Firebase Messaging一次取消订阅所有主题

有没有办法一次取消订阅所有主题?

我正在使用Firebase Messaging从订阅的某些主题接收推送通知,不知何故,我需要取消订阅所有主题,而不必逐个取消订阅.那可能吗?

android firebase firebase-cloud-messaging

23
推荐指数
1
解决办法
2万
查看次数

无法解决:play-services-tasks

我已经尝试将FCM添加到我的Android应用程序中近48小时了.我在Android Studio上继续遇到这两个错误.我已经尝试过这篇文章中的所有解决方案.我仍然无法解决它.

我希望将firebase云消息集成到我的应用程序中.所以我做了以下事情.

  • 在firebase控制台中创建了一个应用程序
  • 包含.json配置文件
  • 添加了SDK
  • implementation 'com.google.firebase:firebase-messaging:17.0.0' (在应用程序级别gradle中)
  • apply plugin: 'com.google.gms.google-services' (在app level gradle文件的最后一行)
  • classpath 'com.google.gms:google-services:4.0.1' (在项目级别gradle中)
  • 添加了存储库 google()(在项目级别gradle中)

我已尝试多次同步,并继续收到错误

无法解决:play-services-tasks打开文件

无法解决:play-services-basement打开文件

另外,我正在使用gradle插件3.1.3

    classpath 'com.android.tools.build:gradle:3.1.3'
Run Code Online (Sandbox Code Playgroud)

有人可以请你帮我一把.

android firebase firebase-cloud-messaging

23
推荐指数
3
解决办法
1万
查看次数

Firebase Messaging v1 401 项目不允许错误

我正在使用 firebase admin sdk 运行节点服务器。但是,每次我尝试从服务器发送推送通知时,都会收到 401 错误。

这是我收到的确切错误:

  errorInfo: {
code: 'messaging/authentication-error',
message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions. See https://firebase.google.com/docs/admin/setup for setup instructions. Raw server response: "<HTML>\n' +
  '<HEAD>\n' +
  '<TITLE>PROJECT_NOT_PERMITTED</TITLE>\n' +
  '</HEAD>\n' +
  '<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n' +
  '<H1>PROJECT_NOT_PERMITTED</H1>\n' +
  '<H2>Error 401</H2>\n' +
  '</BODY>\n' +
  '</HTML>\n' +
  '". Status code: 401.'
},
codePrefix: 'messaging'
Run Code Online (Sandbox Code Playgroud)

我不太清楚为什么我没有该项目的权限。我已经设置了我的服务帐户,并下载了 .json 文件。我什至进入 gcloud 平台并尝试添加任何看起来正确的权限。以下是与我的服务帐户关联的所有权限:

权限

我在本地运行服务器,并像这样初始化应用程序:

const …
Run Code Online (Sandbox Code Playgroud)

javascript firebase firebase-cloud-messaging firebase-admin

23
推荐指数
2
解决办法
2万
查看次数

Google Firebase Downstream消息的http post请求的"Authorization"部分是什么?

我想尝试使用谷歌的FCM消息服务发送消息,正如文档所说,http请求应该是这样的:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我不知道Authorization应该是什么价值,当我删除这个标题并发出请求时,我得到错误401:Unauthorized.我认为这必须是某种api密钥或者其他东西,但我在我的项目中找不到它.谁能帮我?

PS:出于测试目的,我目前正在使用此站点向我的设备发送消息

android push-notification firebase google-cloud-messaging firebase-cloud-messaging

22
推荐指数
1
解决办法
1万
查看次数

适用于iOS的Google Firebase推送通知无法在生产环境中使用

我正在使用Google Firebase云消息传递API(FCM)向我的iOS应用发送推送通知. 当我在具有开发配置文件+开发推送通知(沙盒)证书的设备上测试应用程序时,我可以成功地使用推送通知.

但是我无法让它在生产环境中工作.我使用正确的生产配置文件和生产推送通知证书进行了临时构建.并通过iTunes将IPA文件同步到设备进行测试(不是直接来自xcode).我仍然无法从firebase控制台接收推送通知.

我已经将正确的开发和生产证书(带私钥)上传到firebase.我已经仔细检查过每一个可能出错的步骤,但是仍然无法找到问题.有没有办法解决这个问题?或者是不是可以将生产环境通知发送到AdHoc构建?

xcode apple-push-notifications ios firebase firebase-cloud-messaging

22
推荐指数
2
解决办法
5644
查看次数

应用关闭时的Firebase通知

我在Android应用程序中实现了Firebase通知.当我的应用程序运行时,将显示包含我的自定义布局的通知,但是当应用程序未运行时,通知将以默认布局显示.如何在应用程序未运行时将通知布局更改为我的布局.此外,我存储共享首选项以允许用户切换通知.但是当应用程序未运行时,无论如何都会显示通知.怎么能实现呢?

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if(SettingsFragment.getReceiceNotification()){ //if user wants to receive notification

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.push_notification_layout);

    remoteViews.setImageViewResource(R.id.push_notif_icon,R.mipmap.ic_bird_black);

    Intent intent = new Intent(this,MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);


    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setContent(remoteViews);
    notificationBuilder.setContentTitle("Radyo Türkku?u");
    notificationBuilder.setContentText(remoteMessage.getNotification().getBody());

    notificationBuilder.setAutoCancel(true);
    notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
    notificationBuilder.setContentIntent(pendingIntent);
    remoteViews.setTextViewText(R.id.push_title, "Radyo Türkku?u");
    remoteViews.setTextViewText(R.id.push_context, remoteMessage.getNotification().getBody());
    //notificationBuilder.setLights (ContextCompat.getColor(MainActivity.context, R.color.pushColor), 5000, 5000);
    notificationManager.notify(0,notificationBuilder.build());
    }

}
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging firebase-notifications

22
推荐指数
2
解决办法
3万
查看次数

Firebase handleIntent AbstractMethodError

当我在Android上收到推送通知时,我收到以下错误.我似乎无法找到任何有关它的信息.有人可以帮忙吗?我真的很茫然.

致命异常:pool-1-thread-1进程:com.mycompany.myerror,PID:22712 java.lang.AbstractMethodError:abstract method"void com.google.firebase.iid.zzb.handleIntent(android.content.Intent)"来自java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)的com.google.firebase.iid.zzb $ 1.run(未知来源),位于java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java) :588)在java.lang.Thread.run(Thread.java:818)

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:support-v4:25.3.0'
    compile 'com.android.support:design:25.3.0'
    //https://developers.google.com/android/guides/setup
    compile 'com.google.android.gms:play-services-places:10.2.1'
    compile 'com.google.android.gms:play-services-maps:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.android.gms:play-services-vision:10.2.1'
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.journeyapps:zxing-android-embedded:3.5.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

FirebaseMessagingService.java

public class FirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "FCM Service";

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) { …
Run Code Online (Sandbox Code Playgroud)

android push-notification firebase firebase-cloud-messaging

22
推荐指数
2
解决办法
9213
查看次数

Apple Push Notification 服务服务器证书更新

2021 年 3 月 29 日,与 Apple 推送通知服务的基于令牌和证书的 HTTP/2 连接必须包含新的根证书 (AAACertificateServices 5/12/2020),以取代旧的 GeoTrust Global CA 根证书。为确保无缝过渡并避免推送通知传递失败,请在 3 月 29 日之前验证 HTTP/2 接口的新旧根证书都包含在每个通知服务器的信任存储中。

请注意,此时无需更新 Apple 向您颁发的 Apple Push Notification 服务 SSL 提供商证书。

我收到了关于更新推送通知证书的电子邮件。我已将 FCM (Firebase) 配置为使用 APNs 身份验证密钥发送推送通知。我还没有为推送通知生成任何证书。

我需要改变什么吗?

ssl apple-push-notifications ios firebase firebase-cloud-messaging

22
推荐指数
1
解决办法
3313
查看次数