这是我的清单
<service android:name=".fcm.PshycoFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".fcm.PshycoFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
当应用程序处于后台并且通知到达时,默认通知将会运行并且不会运行我的代码onMessageReceived.
这是我的onMessageReceived代码.如果我的应用程序在前台运行,而不是在后台应用程序时,则调用此方法.如何在应用程序处于后台时运行此代码?
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See …Run Code Online (Sandbox Code Playgroud) 这是我的build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-analytics:9.0.2'
compile 'com.google.firebase:firebase-ads:9.0.2'
compile 'com.google.firebase:firebase-crash:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
应用程序恢复时,应用程序会冻结.它给anr(活动没有响应)错误.
游戏服务9.0+或firebase有什么问题吗?
我正在使用Google登录使用Firebase身份验证,但我想从其他活动中退出,但是当我使用此方法注销时,该方法可以完全从同一活动中运行,但不能与其他活动一起使用.这是方法.
public void logOut() {
mAuth.signOut();
// Google sign out
Auth.GoogleSignInApi.signOut(googleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
authorizeUser(null);
}
});
}
Run Code Online (Sandbox Code Playgroud)
但是当使这个方法静态并且googleApiClient静态时,它仍然不起作用,当我只执行时
FirebaseAuth.getInstance().signOut();
Run Code Online (Sandbox Code Playgroud)
我得到的错误就是这个(logcat)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.igov, PID: 21316
java.lang.IllegalStateException: GoogleApiClient is not connected yet.
at com.google.android.gms.internal.zzoe.zzd(Unknown Source)
at com.google.android.gms.internal.zzoh.zzd(Unknown Source)
at com.google.android.gms.internal.zzof.zzd(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzc.signOut(Unknown Source)
at com.igov.design.LoginActivity.logOut(LoginActivity.java:159)
at com.igov.design.LoginActivity$2.onClick(LoginActivity.java:62)
at android.view.View.performClick(View.java:5198)
at com.igov.design.MainActivity.onNavigationItemSelected(MainActivity.java:101)
at android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:152)
at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810)
at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957)
at android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:318)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95) …Run Code Online (Sandbox Code Playgroud) 我没有得到unified_receipt应用程序购买收据中苹果沙盒中的开发人员文档中所述的信息。
根据他们的文档:https ://developer.apple.com/documentation/appstoreservernotifications/responsebody
重要的
以下顶级对象计划弃用:latest_receipt、latest_receipt_info、latest_expired_receipt 和latest_expired_receipt_info。更新任何现有代码以依赖 Unified_receipt 中的以下对象:latest_receipt 和latest_receipt_info。
但在我的回应中,我没有得到unified_receipt。
我有一个场景,我必须在特定时间使用 WorkManager 向用户发出通知。
我如何在特定时间安排工作,即使用户强制杀死应用程序,它也应该显示出来。或应用程序未运行。
我当前的代码如下:
Data d = new Data.Builder().putInt(IntentConstants.SCHEDULE_ID, scheduleData.getScheduleID()).build();
OneTimeWorkRequest compressionWork =
new OneTimeWorkRequest.Builder(ScheduleWorker.class)
.setInputData(d)
.build();
WorkManager.getInstance().enqueue(compressionWork);
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中实现离线打卡功能,截至目前我正在使用系统日期和时间,但用户可以从设备设置中更改日期和时间,因此它不可靠,这就是为什么我想要不受设备日期和时间影响的真实实际时间。