android - GCM on app and on aar. Push notifications sent to the aar are also received by the app -


i've created library project uses gcm receive push notifications. while installed library on app does not have push notifications enabled, i'm receiving , parsing push notifications expected.

the problem if app has implementation of gcm.

i've faced issue pushes sent library not received. because library registered in manifest com.google.android.gms.gcm.gcmreceiver. overcome this, in library, i've created class extends gcmreceiver , register in library manifest. like:

    <receiver         android:name=".gcm.custompushnotificationsreceiver"         android:exported="true"         android:permission="com.google.android.c2dm.permission.send" >         <intent-filter>             <action android:name="com.google.android.c2dm.intent.receive" />             <!--for pre-4.4 kitkat devices-->             <action android:name="com.google.android.c2dm.intent.registration" />             <category android:name="com.my.package" />         </intent-filter>     </receiver> 

in custompushnotificationsreceiver in onreceive check from field in intent , if destined library, start service in library responsible receiving push notifications.

this approach has faults. 1 - in custompushnotificationsreceiver receive pushes destined app getting access it's contents (the app using library may not want this). 2 - pushes sent library received app app has verify if push received destined her.

i can override issue 2 if app gets registered custompushnotificationsreceiver. custompushnotificationsreceiver handle pushed if app or library. not solve issue 1.

is possible "mark" push messages received package destined to?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -