0

I'm implementing an sdk which uses firebase (every app that uses the sdk is subscribing to firebase and has the google-services.json in its context, and when i send a push from my server to EventsService listed below, i receive the push in onMessageRecieved.

AppManifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.sampleapplication">

    ...

    <application
       ...

        <service android:name=".EventsService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

    </application>

</manifest>

EventsService.java :

public class EventsService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage message) {
        ...
    }

}

SdkManifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.my.sdk">

    ...

    <application
       ...

        <service android:name=".SdkEventsService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

    </application>

</manifest>

Now, i want SdkEventsService to receive the event as well, and basically catch the event in the sdk as well. However, SdkEventsService receives the push from firebase ONLY if the EventsService defined in the app is deleted.

Fyi, it seems that the issue is really : how to define 2 services that catch com.google.firebase.MESSAGING_EVENT simultaneously and are kinda independant of each other.

  1. I tried setting SdkEventsService a lot of tags (android:exported="true" fe), but none worked.
  2. I don't want EventsService to 'alert' the sdk when a push is received, because i don't want to rely on the client to notify the sdk.
  3. I don't want EventsService to extend a base class from the sdk, which will receive the push, because well.. it's quite ugly and not professional.
  4. Basically, i would like a minimum client interference, and i wish the process to be transparent as much as possible.

just saying : this question is really not my issue, and i haven't find anything like this here :(

Dus
  • 4,052
  • 5
  • 30
  • 49
  • 1
    Your problem is due to this: https://stackoverflow.com/a/8606179/2910520. One option is to launch the SdkEventsService from the EventsService and sincerely i dont know why you shouldn't "rely on the client to notify the sdk" because is the same thing than relying on the Push notification system and your EventsService – MatPag Jun 21 '17 at 10:05
  • :( i don't want to relay of the developers to call a method when they receive a push. what if a developer 'forgets' to do so ? – Dus Jun 21 '17 at 10:07
  • Sincerely i'm not understanding what you are building, If a library or a framework or something similar and if this choice is the only available for your use case. But beside this, if you write a good documentation you will eliminate 95% of implementation problems by developers. – MatPag Jun 21 '17 at 10:09
  • exatly... not 100% ... – Dus Jun 21 '17 at 10:11
  • Left 5% is distraction or lazyness of developers and there is no way to reduce this number to 0, even if you check the Google documentation or every library produced in the world, you have no chance to prevent some developers to create issues in forum or github only because they didn't read all the documentation :D – MatPag Jun 21 '17 at 10:13

0 Answers0