OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

NotificationExtenderService - app crash on start #216

Closed ss-andrii closed 2 years ago

ss-andrii commented 3 years ago

Description: I need to silent notifications. I am following the docs: https://documentation.onesignal.com/docs/service-extensions#notification-extender-service

I am trying to do a very basic implementation just to test it. So in the service where I extend the NotificationExtenderService I just return true.

The app builds fine but on start it crashes every time

Environment OneSignal Xamarin SDK 3.10.1

Steps to Reproduce Issue:

  1. My NotificationExtenderService implementation:
public class OneSignalExtenderService : NotificationExtenderService
    {
        protected override void OnHandleIntent(Intent intent) {}
        protected override bool OnNotificationProcessing(OSNotificationReceivedResult p0)
        {
            return true;
        }
    }
  1. Android manifest
<service
   android:name=".OneSignalExtenderService"
   android:permission="android.permission.BIND_JOB_SERVICE"
   android:exported="false">        
   <intent-filter>
    <action android:name="com.onesignal.NotificationExtender" />
   </intent-filter>
</service>

Error in console:

java.lang.RuntimeException: Unable to instantiate service <package_name>.OneSignalExtenderService: java.lang.ClassNotFoundException: Didn't find class "<package_name>.OneSignalExtenderService" on path: DexPathList[[zip file ...
rgomezp commented 3 years ago

Howdy, Please note you have to implement the Extender Service in native code.

Hope that helps.

ss-andrii commented 3 years ago

Yes, Extender Service is implemented in native code. When I replace in manifest

android:permission="android.permission.BIND_JOB_SERVICE"

on

android:permission="false"

app is start successful, but when I send push notification it's crashed with:

'Unable to start receiver com.onesignal.GcmBroadcastReceiver: java.lang.IllegalArgumentException: Scheduled service ComponentInfo{<package_name>/<package_name>.OneSignalExtenderService} does not require android.permission.BIND_JOB_SERVICE permission'
jkasten2 commented 3 years ago

@AndriiSvitSoft It looks like you have this correct. Based on the error you got the entry matches what has fixed it for others. https://github.com/OneSignal/OneSignal-Android-SDK/issues/351#issuecomment-340552046

Could you share you full AndroidManifest.xml? As well as which Android versions you have tested this on?

jkasten2 commented 2 years ago

Closing due to inactivity.