GCM: Yet another BIND_JOB_SERVICE permission error — IntentService to JobIntentService
Clash Royale CLAN TAG#URR8PPP
GCM: Yet another BIND_JOB_SERVICE permission error — IntentService to JobIntentService
Issue: since I now need to target Oreo to submit apps, I have to change my RegistrationIntentService to inherit from JobIntentService instead of IntentService. I am still using GCM, but that should make no difference. Note that this is Xamarin C# code.
The error is that I always get an exception in my static EnqueueWork method saying:
Scheduled service ComponentInfocom.emergencyuniversity.EUAlert/md58d0653b4094c2dbc798f6d984e1c1386.RegistrationIntentService does not require android.permission.BIND_JOB_SERVICE permission
I've changed OnHandleIntent to OnHandleWork, and I now call the static EnqueueWork convenience method in places where I used to call StartService.
var intent = new Intent (this, typeof (RegistrationIntentService));
RegistrationIntentService.EnqueueWork(this, intent); // instead of StartService(intent)
My EnqueueWork, that gets the exception:
public static void EnqueueWork(Context context, Intent work)
Java.Lang.Class cls = Java.Lang.Class.FromType(typeof(RegistrationIntentService));
try
EnqueueWork(context, cls, GCMEUA_JOB_ID, work);
catch (Exception ex)
Console.WriteLine("Exception: 0", ex.Message);
In the manifest, I added:
<service android:name=".RegistrationIntentService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
I've also tried exported false, and putting that permission in a bunch of different places.
One other change I made was removing the following due to compiler errors:
public RegistrationIntentService() : base("RegistrationIntentService")
In addition to the Android docs, I have probably read every post imaginable about this, including:
https://android.jlelse.eu/keep-those-background-services-working-when-targeting-android-oreo-sdk-26-cbf6cc2bdb7f
https://medium.com/til-kotlin/jobintentservice-for-background-processing-on-android-o-39535460e060
JobService does not require android.permission.BIND_JOB_SERVICE permission
Why do I still get this error? Any help would be greatly appreciated. Thanks.
I agree that I need to move to FCM, and I will do that very soon, but even though it was deprecated in April I can't believe Firebase would leave me high and dry. There must be something wrong with my EnqueueWork code.
– fbs419
Aug 8 at 22:24
That being said, the first thing I tried was to bump the priority of the GCM message to high, as that is supposed to whitelist you. That didn't work, however, so I wondered if that only applied to FCM. But I still think it is possible to solve this. I just haven't figured it out yet.
– fbs419
Aug 8 at 22:25
Well -- it's a process. Got past the BIND_JOB_SERVICE error by putting: Service(Name = "MyPackage.RegistrationIntentService", Permission = "android.permission.BIND_JOB_SERVICE", Exported = true)] to the C# file for the service. Next error is android.support.v4.content.ContextCompat being inaccesssible with com.google.android.gms.iid.zzd which means I undoubtedly have to update the GooglePlayServices nuget stuff, etc. Which is not working either. Eventually, I imagine I should be able to get past all this.
– fbs419
Aug 9 at 14:47
1 Answer
1
OK, this is solved. The last issue was solved by upgrading to a later NuGet package for Xamarin.GooglePlayServices.Gcm, and its associated libraries. Everything now working correctly.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
"I am still using GCM, but that should make no difference." - Yes it does. GCM is now officially deprecated. The reason why devs are encouraged to migrate to FCM is simply because it's the latest version. It contains fixes for bugs that existed during GCM. If you still continue to use GCM, then there's no guarantee about it's behavior anymore.
– AL.
Aug 8 at 3:37