BroadcastReceiver onReceive not called from custom Unity android plugin

I’m writing my own Unity plugin for firing timed local notifications on Android. I’ve managed to make the necessary JNI calls through Unity but for some reason the onReceive method of my BroadcastReceiver is not called. Below is the code for classes included in my plugin. The scheduleNotification method is called from a C# script but there is no notification after the time specified by ‘interval’ has passed.

The plugin is added as a jar file in Unity (placed at Assets/Plugins/Android/). I also have a res folder at this path which gives me the icons to be used with the notification. What am I doing wrong here? Why is my BroadcastReceiver not called?

public class PushPlugin extends UnityPlayerActivity
    private static final String TAG = "PushPlugin_Unity";
    private static PushPlugin instance = null;

    protected void onCreate(Bundle myBundle) {
        instance = this;

    public static void scheduleNotification(String notificationID,
                                        String message, String objectId, int interval) {

        // get a Calendar object with current time
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.SECOND, interval);

        Intent intent = new Intent(UnityPlayer.currentActivity.getApplicationContext(), PluginBroadcastReceiver.class);
        intent.putExtra("notificationID", notificationID);
        intent.putExtra("message", message);
        intent.putExtra("objectId", objectId);
        PendingIntent sender = PendingIntent.getBroadcast(UnityPlayer.currentActivity.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        // Get the AlarmManager service
        AlarmManager am = (AlarmManager) UnityPlayer.currentActivity.getApplicationContext().getSystemService(UnityPlayer.currentActivity.getApplicationContext().ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

public class PluginBroadcastReceiver extends BroadcastReceiver {
public static Bundle extras = new Bundle();
static final String TAG = "PushPlugin-BR";
public static final int NOTIFICATION_ID = 1;
private NotificationManager mNotificationManager;
NotificationCompat.Builder builder;
Context ctx;

public void onReceive(Context context, Intent intent) {
	ctx = context;
	// Local notification.
	Bundle bundle = intent.getExtras();
	String notificationID = bundle.getString("notificationID");
	String message = bundle.getString("message");
	String objectId = bundle.getString("objectId");

	Log.v(TAG, "Received local notification of type: " + notificationID
			+ " and message: " + message + " and objectId " + objectId);

	sendNotification(message, notificationID, objectId);

// Put the GCM message into a notification and post it.
private void sendNotification(String msg, String notifID, String objectID) {
	mNotificationManager = (NotificationManager) ctx

    Intent intent = new Intent(ctx, PushPlugin.class);
	PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0,
			intent, PendingIntent.FLAG_UPDATE_CURRENT);

    extras.putString("notificationID", notifID);
    extras.putString("message", msg);
    extras.putString("objectId", objectID);
	NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
    Resources res = ctx.getResources();
    int icon = res.getIdentifier("app_icon", "drawable", UnityPlayer.currentActivity.getPackageName());
	mBuilder.setContentTitle("Plugin Test");
	Log.v(TAG, "-------- notification received: " + msg);
	mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
<uses-sdk android:minSdkVersion="8" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- gcm -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="" />

<permission android:name=""
android:protectionLevel="signature" />
<uses-permission android:name="" />

<application android:label="@string/app_name">
    <activity android:name=".PushPlugin"
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        android:permission="" >
            <action android:name="" />
            <category android:name="" />
    <service android:name=".PluginIntentService" />

Ok… I found the solution for this. Just declare the BroadCastReceiver in BOTH the AndroidManifest.xml ie in Unity and in your JAR file as a receiver.

<receiver android:name="">

as said by @liortal.

Not sure if that may solve the issue, but in your AndroidManifest.xml, try declaring the BroadcastReceiver using its full name:

<receiver android:name="">

I remember having issues with having it the way you shoe in your question.

Also, for the way you’re calling the broadcast receiver in your example, you do not need to declare anything but its full name in the manifest (you can keep only the part as i show above).