我正在AWS为我的android项目使用资源,我打算为我的项目添加推送通知服务AWS SNS.有几个问题困扰我.我没有发现任何关于这些的问题,除了一两个但解释不清楚.
1. AWS支持FCM吗?SNS与...合作GCM.但谷歌建议使用FCM代替GCM.我没有找到AWS支持FCM.
2. AWS即使在发送推送通知后,还是将消息(或数据)存储到他们的数据库中?
3.我试过把FCM api密钥放在SNS应用平台上,显示无效参数为什么?
android amazon-web-services amazon-sns google-cloud-messaging firebase-cloud-messaging
自从我更新到Android SDK工具25.1.6和Android支持存储库32.0.0(今天早上)后,我收到以下错误,我没有更改我的代码中的任何内容,它仍在我的同事计算机上运行(Android SDK工具) 25.1.1 + Android支持存储库30.0.0).
java.lang.IncompatibleClassChangeError: The method
'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)'
was expected to be of type virtual but instead was found to be of type direct
(declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.xxxxxxx.utils.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:55)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.os.HandlerThread.run(HandlerThread.java:61)
Run Code Online (Sandbox Code Playgroud)
这是一段崩溃的代码:
InstanceID instanceID = InstanceID.getInstance(this); // <-- crash here
String instanceIDToken = instanceID.getToken(getString(R.string.google_app_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Run Code Online (Sandbox Code Playgroud)
当我尝试从Google Cloud Messaging获取令牌时.
我正在使用分割的播放服务在Gradle中导入GCM:
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile …Run Code Online (Sandbox Code Playgroud) android google-cloud-messaging android-gradle-plugin firebase-cloud-messaging
一旦我将 flutter 更新到 1.12.13 版,我就发现了这个问题并且无法修复它。我按照firebase_messaging教程发送的,得到以下错误:“错误:类型不兼容:PluginRegistry无法转换为FlutterEngine GeneratedPluginRegistrant.registerWith(registry);”我的代码如下:
package io.flutter.plugins;
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("messages","Messages", NotificationManager.IMPORTANCE_LOW);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
}
@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
}
Run Code Online (Sandbox Code Playgroud) firebase flutter firebase-cloud-messaging flutter-dependencies
这是我第一次使用FCM.
我从firebase/quickstart-android下载了一个示例,我安装了FCM Quickstart.But我甚至无法从日志中获取任何令牌,甚至点击应用程序中的LOG TOKEN按钮.
然后我尝试使用Firebase控制台发送消息并设置为我的应用程序包名称.我收到任何传入消息.
我想知道可以使用FCM吗?GCM一切正常.
解:
因为我不是Android开发人员,只是一个后端开发人员.所以我需要一些时间来解决它.在我看来,示例应用程序中存在一些错误.
码:
RegistrationIntentService.java
public class RegistrationIntentService extends IntentService {
private static final String TAG = "RegIntentService";
public RegistrationIntentService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
String token = FirebaseInstanceId.getInstance().getToken();
Log.i(TAG, "FCM Registration Token: " + token);
}
}
Run Code Online (Sandbox Code Playgroud)
MyFirebaseInstanceIDService.java
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
/**
* Called if InstanceID token is updated. This may occur if the security of …Run Code Online (Sandbox Code Playgroud) 搜索文档后,我找不到任何有关如何使用FCM将设备发送到设备消息的信息,而无需使用外部服务器.
例如,如果我正在创建一个聊天应用程序,我需要向用户发送有关未读消息的推送通知,因为它们不会一直在线,我不能在后台始终连接到持久服务实时数据库,因为这太资源了.
那么当某个用户"B"向他/她发送聊天消息时,如何向用户"A"发送推送通知?我是否需要外部服务器,还是仅使用Firebase服务器?
在我MainActivity的日志中,我可以看到使用的令牌FirebaseInstanceId.getInstance().getToken(),它显示生成的令牌.但似乎在我 MyFirebaseInstanceIDService扩展到的地方FirebaseInstanceIdService,onTokenRefresh()没有被调用,在这个函数中,据说令牌最初是在这里生成的.我需要打电话给我,sendRegistrationToServer()这就是为什么我想知道它为什么不进入的原因onTokenRefresh().
这是我的代码
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
sendRegistrationToServer(refreshedToken);
}
}
Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-notifications
我在SO上读过类似的问题,然而,我无法从中得到正确的答案.
我有一个系统,我们向大约500个设备发送通知.
不幸的是,许多这些设备没有收到通知.我发现OPPO F1系列手机特别没有收到通知.
我发现,如果应用程序从多任务托盘中停止,则会发生这种情况.我该如何解决这个问题?
更新:我观察到当我从任务托盘关闭应用程序时,我的应用程序被强制停在应用程序管理器中.当我从任务托盘关闭Whatsapp时,仍然没有强制停止.怎么被Whatsapp处理?
android firebase firebase-cloud-messaging firebase-notifications
根据这个 SO线程,我知道存在版本冲突,但是在谷歌的新版本之后问题仍然存在.
错误:任务':app:processDebugGoogleServices'的执行失败.请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息,请访问https://bintray.com/android/android-tools/com.google.gms.google-services/)或将com.google.android.gms的版本更新为10.0.1.
我的build.gradle(模块:app)
....
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
现在需要做哪些改变?
android firebase google-play-services firebase-cloud-messaging
我正在尝试测试Firebase云消息传递API,因为控制台无法使用所有功能(特别是在应用程序处于后台时自定义通知).但由于某些原因,我无法让它工作,它总是出现401错误.我调查了这个的原因,并在重新生成新的服务器密钥后尝试了它,但错误保持不变.令人惊讶的是,当我生成新的服务器密钥时,它不会反映在Firebase控制台中,并且它将服务器密钥显示为空.此外,我尝试将我的IP地址添加到服务器白名单IP但仍然没有运气.我附上了一个我用Postman做的请求的截图(我用服务器密钥代替serverKey.
我想知道在不推荐使用getToken()的情况下,获取Firebase令牌以发送推送通知的正确方法是什么.