Heloo,我正在构建一个应用程序,我通过Firebase控制台使用推送通知.我想知道简单推送通知和云消息之间的区别是什么?来自云消息传递的消息是数据消息(具有密钥和值),通知只是没有密钥和值的文本吗?我是对的吗?
google-cloud-messaging firebase-cloud-messaging firebase-notifications
在一个应用程序中对Firebase云消息传递的不同主题数量有任何限制吗?
我正在开发一个应用程序,我必须将该项目带到GitHub.现在,我必须制作gitIgnore文件.我知道该文件用于忽略项目中的某些指定文件.我使用gitIgnore.io服务,我收到了生成的文件.这是我的gitIgnore文件:
# Created by https://www.gitignore.io/api/android
### Android ###
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea/workspace.xml
# Keystore files
*.jks
### Android …Run Code Online (Sandbox Code Playgroud) 我正在开发一个我想使用Fused Location Provider的应用程序.但我有一些疑问,还有几个问题.
你有什么意见?提前致谢.
我正在构建一个使用Firebase云消息传递的应用程序.但我有些疑惑.我想知道我们可以在一个应用实例中制作多少主题?
在官方文档中,它写道
当单个应用程序实例订阅过多的主题时
它检索错误TOO_MANY_TOPICS.
我想知道允许多少主题.我知道我们没有关于订阅者数量的限制,这没关系,但我想知道我们可以在一个应用实例中制作多少主题.感谢任何帮助.
我正在开发使用Firebase Cloud Messaging的应用程序。我正在为我的应用程序使用干净的体系结构。我想知道哪里(在哪一层:数据,域,表示形式)是放置我的名为MyFirebaseMessagingService和MyFirebaseInstanceServiceID的类的最佳解决方案?这些是我的类:myFirebaseMessagingService:
public class myFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG="MyFirebaseMsgService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d("onMessageReceived", "Pozvana funkcija onMessageReceived");
Log.d(TAG, "From " + remoteMessage.getFrom());
Log.d(TAG, "Body " + remoteMessage.getNotification().getBody());
Log.d(TAG, "Location " + remoteMessage.getNotification().getClickAction());
Log.d(TAG, "Value " + remoteMessage.getData().get("click_action"));
sendNotification(remoteMessage);
Log.d("Function called", "sendNotification");
}
private void sendNotification(RemoteMessage remoteMessage) {
Intent intent = new Intent(myFirebaseMessagingService.this, MainActivity.class);
intent.putExtra("click_action", "goToFragment1");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notification=new NotificationCompat.Builder(this)
.setSmallIcon(logo)
.setContentText(remoteMessage.getNotification().getBody()) …Run Code Online (Sandbox Code Playgroud) 大家好,我正在开发一个使用 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) 我在 Java 中遇到 Date 和 SimpleDateFormat 对象的一些问题。我知道我需要在 Java 8 中使用新的日期和时间 API 来切换它们,我想这样做,但我有一个问题。当我从数据库中检索我的日期时(它是 SimpleDateFormat 并且我无法更改它),并且当我想添加一些小时(例如下午 4 点),然后我需要在用户从下拉列表中选择的时区中(假设美国/加拉加斯),所以我希望美国/加拉加斯的结果是 16 小时,但在我的情况下是 16 小时 UTC + UTC 和美国/加拉加斯之间的差异。这是我的代码:
Date startDate -> it's value is Tue Feb 23 20:00:00 CET 2021
Date date = new SimpleDateFormat("yyy-MM-dd").format( startDate + 4:00PM + America/Caracas);
Run Code Online (Sandbox Code Playgroud)
但是,奇怪的是,这种格式化广告 4 PM 值但不知何故忽略了时区的那部分。所以,相反,我在美国/加拉加斯有 20 小时,我在 UTC 时间有 20 小时。有人可以帮助我吗?