从上图可以看出,所有推送通知始终显示零打开率,尽管我非常确定至少有 1% 会打开推送通知。
我想跟踪一天内每条发送消息的打开率。
但如果从 Firebase 控制台打开基于当天的总体报告,它将跟踪一天内发送的所有消息的打开率,如下图所示:
那么为什么第一张图片中每条发送消息的打开率总是显示为零?
在 Android 中我使用这个 gradle:
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.8@aar') {
transitive = true;
}
我的消息服务类:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
//*********** Called when the Notification is Received ********//
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Bitmap notificationBitmap = null;
String notification_title, notification_message, notification_image = "";
if (remoteMessage.getData().size() > 0) {
notification_title = remoteMessage.getData().get("title");
notification_message = remoteMessage.getData().get("message");
notification_image = remoteMessage.getData().get("image");
} else {
notification_title = remoteMessage.getNotification().getTitle();
notification_message = remoteMessage.getNotification().getBody();
}
notificationBitmap = getBitmapFromUrl(notification_image);
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
NotificationHelper.showNewNotification
(
getApplicationContext(),
notificationIntent,
notification_title,
notification_message,
notificationBitmap
);
}
public Bitmap getBitmapFromUrl(String imageUrl) {
if ("".equalsIgnoreCase(imageUrl)) {
return null;
}
else {
try {
URL url = new URL(imageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
return BitmapFactory.decodeStream(input);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
}
这里出了什么问题?
我们遇到了类似的问题,这是由于缺少 Firebase Analytics 库引起的。
文档适用于安卓 https://firebase.google.com/docs/android/setup:
第 4 步:将 Firebase SDK 添加到您的应用
...
// 添加适用于 Google Analytics 的 Firebase SDK 的依赖项
实施 'com.google.firebase:firebase-analytics'
文档for iOS https://firebase.google.com/docs/ios/setup:
第 4 步:将 Firebase SDK 添加到您的应用
...
4. 选择您要使用的 Firebase 库。
如果您的 Firebase 项目中启用了 Google Analytics,请确保添加
Firebase 分析。对于没有 IDFA 收集功能的 Analytics,请添加
相反,FirebaseAnalyticsWithoutAdId。
Google Analytics 在管理 UI 中也有设置指南(管理 - 属性 - 数据流,选择流,单击“SDK 设置说明”):
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)