I am doing a push notification using GCM that is written in an SDK,developer needs to add my SDK as library project ,my SDK uses the context from the developer and creates Registeration Id ,but when i push from an server using the ID i could not receive any notification in fact my receiver class is not invoked
Manifest file in SDK has
<receiver
android:name=".GcmBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.mysdk" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
permission has
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.mysdk.permission.C2D_MESSAGE"
/>
<uses-permission android:name="com.mysdk.permission.C2D_MESSAGE" />
Manifest in app that has my SDK as library file
<receiver
android:name="com.mysdk.GcmBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.mysdk" />
</intent-filter>
</receiver>
<service android:name="com.mysdk.GcmIntentService" />
permission has
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.mysdk.permission.C2D_MESSAGE"
/>
<uses-permission android:name="com.mysdk.permission.C2D_MESSAGE" />
can any one suggest what went wrong ,May be is this possible ,i.e. sending notification from SDK
The app that uses your SDK shouldn't use com.mysdk
for the GCM permissions and for the category of the broadcast receiver intent-filter. Instead it should use its own package name.
Below I marked the changes you should make in your app's manifest:
<receiver
android:name="com.mysdk.GcmBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="CHANGE_TO_YOUR_APPS_PACKAGE_NAME" />
</intent-filter>
</receiver>
<service android:name="com.mysdk.GcmIntentService" />
<permission android:name="CHANGE_TO_YOUR_APPS_PACKAGE_NAME.permission.C2D_MESSAGE"/>
<uses-permission android:name="CHANGE_TO_YOUR_APPS_PACKAGE_NAME.permission.C2D_MESSAGE" />