Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GCMNetworkManager to Firebase Job Dispatcher #194

Open
LouisCAD opened this issue Jun 22, 2016 · 17 comments
Open

Update GCMNetworkManager to Firebase Job Dispatcher #194

LouisCAD opened this issue Jun 22, 2016 · 17 comments

Comments

@LouisCAD
Copy link

LouisCAD commented Jun 22, 2016

Hi!

After reading the GcmNetworkManager docs, I saw something written in red here, at the bottom of the page which says:

When Google Play Services or the client app is updated, all scheduled tasks are removed. GcmNetworkManager invokes the client app’s onInitializeTasks(). Override this function to reschedule necessary tasks.

I looked at the source code (in v2alpha4), and saw that the onInitializeTasks() is NOT overriden, so this means that each time Google pushes an update to Google Play Services, which happens all the time, and each time I publish a newer version of my app, my app will wait until the user starts it again to run the JobManager because it's not rescheduled, right?

If I'm not wrong, can you properly override this method in the library please?

It doesn't seems there's something similar with the framework's implementation, JobScheduler though.

EDIT:

GCMNetworkManager is fading away, letting Firebase Job Dispatcher replace it. This new version seems to no longer require rescheduling after Play Services or app update, but this library needs to use it to benefit from it.

@yigit
Copy link
Owner

yigit commented Jun 23, 2016

We don't have any code to do this work yet but can be added. I'll consider adding this but probably post 2.0.

@LouisCAD
Copy link
Author

How to make sure Jobs are rescheduled in the meantime? Is it that complicated to add before v2 is out of alpha? I mean, isn't this just about calling the same code that scheduled the tasks initially, i.e. a copy/paste or a method call?

@yigit
Copy link
Owner

yigit commented Jun 23, 2016

No it is not because this will require re-querying the database to find such jobs and rescheduling for them (so it is a different logic). The jobs will still be run, is just wont be re-scheduled via the JobScheduler.

I really want to get out v2 so I have to cut somewhere and push for a stable release instead of adding new features.

@LouisCAD
Copy link
Author

I see, and agree, get a stable v2 out has a higher priority. Thanks!

@LouisCAD
Copy link
Author

Congrats for v2 release!

So this will now be addressed soon, right?
I guess there's some things to take into account:
At last Google I/O (2016), some Google services which included GCM got a rebranding, and some API changes too. For GCMNetworkManager, it seems that Firebase Job Dispatcher is now the way to go. Although it means your library will need refactoring to support it, it seems like rescheduling is not needed anymore now, so maybe this issue should be renamed to "Update to Firebase Job Dispatcher"?

@yigit
Copy link
Owner

yigit commented Aug 18, 2016

yea i need to do that :/. Meanwhile, you can probably copy GCM code and make it work for Firebase dispatcher. JobManager only uses a scheduler API so it is generic.

@LouisCAD LouisCAD changed the title Reschedule JobManager jobs when the app or Play Services are updated Update GCMNetworkManager to Firebase Job Dispatcher Aug 18, 2016
@LouisCAD
Copy link
Author

So I edited the name of this issue.
I don't need it ASAP, so I'll wait for it to be officially part of this library, though, so no need to worry or hurry.

@riggaroo
Copy link

This would be great - currently trying to use this with Firebase and the firebase guide says to not use this dependency anymore with FCM
compile 'com.google.android.gms:play-services-gcm:9.4.0'

@LouisCAD
Copy link
Author

LouisCAD commented Sep 14, 2016

I guess this issue, whose Firebase guys still didn't pay any attention is blocking this one, right?
EDIT: issue resolved

@pipipzz
Copy link

pipipzz commented Sep 27, 2016

I updated to FCM from GCM and now when I run the app, I get the following error:

/Users/spark/Documents/galleri5/Android/App/galleri5/app/src/main/java/com/galleri5/android/Galleri5Application.java Error:(152, 40) error: incompatible types: Class<MyGcmJobService> cannot be converted to Class<? extends GcmJobSchedulerService> /Users/spark/Documents/galleri5/Android/App/galleri5/app/src/main/java/com/galleri5/android/services/MyGcmJobService.java Error:(9, 8) error: cannot access GcmTaskService class file for com.google.android.gms.gcm.GcmTaskService not found Error:(11, 5) error: method does not override or implement a method from a supertype Error:org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.

What can I do to resolve this?

@yigit
Copy link
Owner

yigit commented Jan 15, 2017

@pipipzz which version of GCM are you using ? I've tried updating dependency to 10.0.1 but does not create any errors :/. I try to keep version minimal so that it picks app's version but if there is an incompatibility, i'll update.

@LouisCAD
Copy link
Author

@yigit He is not using the GCM dependency but the FCM one

@yigit
Copy link
Owner

yigit commented Jan 15, 2017

@yigit
Copy link
Owner

yigit commented Jan 15, 2017

Basically, i cannot figure out what job queue will gain by moving to firebase (besides additional dependencies). It still uses GCM behind the scenes and job queue already does that.
I think i'll just go ahead and update job queue's dependency to gcm 10.

@LouisCAD
Copy link
Author

@yigit Only the withGcmDep productFlavor of Firebase Job Dispatcher depends and uses GCM behind the scenes if you look closer at the build.gradle file you linked, and that version isn't even updated (still released at 0.5.0 while the latest is 0.5.2). So I think using Firebase Job Dispatcher would be useful for people that don't want to use GCM anymore as it's being replaced by FCM

@mwajeeh
Copy link

mwajeeh commented Mar 19, 2018

I recently moved to FCM and I am unable to compile my code because there is no GCM.
Anyone who moves to FCM can no longer use this library. I guess it is time to add some FcmJobSchedulerService.

error: cannot access GcmTaskService 
public class JobQueueGCMService extends GcmJobSchedulerService {       
 ^   class file for com.google.android.gms.gcm.GcmTaskService not found |  

@ClarkXP
Copy link

ClarkXP commented Apr 2, 2019

@mwajeeh If your minSdkVersion > Lollipop, you can delete GcmJobSchedulerService, holding just FrameworkJobSchedulerService

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants