- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我遵循了互联网上的例子,并在此处和其他网站上复习了许多问题
我构建了我的应用程序,以便它处理 FCM 通知,但我仍然无法找出为什么 FirebaseInstanceIdService 没有被调用。
我在AndroidManifest.xml
中声明了它
<service android:name=".InstanceService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"></action>
</intent-filter>
</service>
<service android:name=".MessageService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"></action>
</intent-filter>
</service>
我的服务是
public class InstanceService extends FirebaseInstanceIdService {
private static final String REG_Token="REG_Token";
@Override
public void onTokenRefresh() {
String recent_token= FirebaseInstanceId.getInstance().getToken(); // get token from the server
Log.d(REG_Token,recent_token); // show device token in Logcat View
}
我查看了 Logcat,但那里没有 REG_Token。
我尝试调试代码并在 Log.d(REG_Token,recent_token);
处停止,但它并没有就此停止。
我认为该服务根本没有被调用,我找不到原因。
最佳答案
The registration token may change when:
- The app deletes Instance ID
- The app is restored on a new device
- The user uninstalls/reinstall the app
- The user clears app data.
这意味着 onTokenRefresh()
方法不会在每次打开应用程序时调用,而只会在这 4 个事件之一发生时调用。
最简单的方法是卸载该应用程序,然后重新安装该应用程序。安装后,打开应用程序,然后查看 logcat(基于您的代码)。
希望这有帮助:)
关于android - FirebaseInstanceIdService 不会被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442481/
我正在创建一个聊天应用程序,根据教程我应该创建这个: Tutorial example 问题是现在这个函数 (FirebaseInstanceIdService) 不再存在,因此我不能使用它。有人会建
FirebaseInstanceIdService 在应用程序的开头启动,我希望它仅在身份验证后生成 token 。 我在 MainActivity 中尝试了这一行(它在身份验证后运行)但它没有用:
我遵循了互联网上的例子,并在此处和其他网站上复习了许多问题 我构建了我的应用程序,以便它处理 FCM 通知,但我仍然无法找出为什么 FirebaseInstanceIdService 没有被调用。 我
希望大家都知道这个类,用于在firebase通知 token 刷新时获取通知 token ,我们从这个类获取刷新的 token ,通过以下方法。 @Override public void onTok
我喜欢在 android studio 中重写我的代码,我是 android 开发的新手我的初始 MyFirebaseInstanceIDService 代码 @Override pu
正如标题所暗示的那样,如果我为 FCM 通知注册了一个 Android 应用程序并且该应用程序在后台运行或有一段时间没有启动并且 token 发生变化,onTokenRefresh()调用? 它会唤醒
我已经为云消息传递实现了 Firebase: https://firebase.google.com/docs/cloud-messaging/android/client#sample-regist
我尝试更新我的应用程序,但当应用程序应该生成 token 时,我显示错误。我的应用程序显示 token 未生成。 我的 firebase 代码如下: import android.util.Log;
因此,我正在尝试为我的应用程序使用 Firebase 云消息传递,但是当我尝试对其进行测试时,即使是示例代码也会向我抛出错误。 public class FirebaseIDService exten
我正在尝试将 FCM 通知添加到我的应用程序,但出于某种原因 FirebaseInstanceId.getInstance().getToken(); 正在返回 null。 因为我没有得到任何堆栈跟踪
public class LoginActivity extends AppCompatActivity { private static final int RC_SIGN_IN = 1;
这个问题已经有答案了: FirebaseInstanceIdService is deprecated (19 个回答) 已关闭 4 年前。 问题是,我想在我的聊天应用中使用 Firebase 云消息
我正在从 GCM 升级到 FCM。在 onTokenRefresh 之外获取 Firebase 设备 token 的正确方法是什么? 我正在尝试获取设备 token ,以便稍后可以在我的服务器上重新启
我想从客户端(android 应用程序)管理主题订阅。我目前正在 onCreate() Activity 中进行。我想知道正确的方法是在 InstanceIdService::onTokenRefre
当我调试时,这部分应用程序不执行,所以我不知道 token 何时刷新,即使我在调试前清除数据或卸载应用程序也是如此。 下图展示了我的代码。 有人能给我解释一下吗? 最佳答案 好的,让我们一步步来 首先
如果我使用教程中提供的代码,我会收到以下警告: Warning CS0618: 'FirebaseInstanceIdService' is obsolete: 'This class is obso
我不知道为什么每当我尝试创建我的应用程序构建时我都会收到此错误。我尝试了很多解决方案但我无法解决这个问题。我不知道是否有任何插件导致问题或者是否有任何我的代码或 firebase 或 firebase
我是一名优秀的程序员,十分优秀!