Cómo utilizar Phonegap Android Plugin de notificación local

Estoy usando phonegap locanotification plugin para android.This es mi primera vez que prueba este complemento Local Notification

Cuando utilicé este plugin con phonegap 2.7.0 primero lanza muchos errores a me.I finalmente resuelto todos los errores por googling.

Cuando ejecuto este ejemplo de ejemplo no recibo ninguna notificación en absoluto

He seguido todos los pasos que se han dado en el archivo readme y el nombre del plugin en config.xml y todos excepto cuando ejecuto esta aplicación de ejemplo no recibo ningún error más cualquier notificación

¿Puede alguien decirme dónde me he equivocado?

index.html:

<script type="text/javascript" charset="utf-8" src="cordova-2.7.0.js"></script> <script type="text/javascript" charset="utf-8" src="LocalNotification.js"></script> <script type="text/javascript"> document.addEventListener("deviceready", appReady, false); function appReady() { if (typeof plugins !== "undefined") { var now = new Date(); now.setSeconds(now.getSeconds() + 10); console.log("Alarm Time Set " + now); plugins.localNotification.add({ date : now, message : "Phonegap - Boooyyyaaaaah!\r\nUpyoass!", ticker : "Yeeeaaaaahhhh!!!", repeatDaily : false, id : 4 }); } }; </script> 

Receptor de alarma.Java

 package com.phonegap.plugin.localnotification; import java.util.Calendar; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; import com.testing.R; /** * The alarm receiver is triggered when a scheduled alarm is fired. This class * reads the information in the intent and displays this information in the * Android notification bar. The notification uses the default notification * sound and it vibrates the phone. * * @author dvtoever */ public class AlarmReceiver extends BroadcastReceiver { public static final String TITLE = "ALARM_TITLE"; public static final String SUBTITLE = "ALARM_SUBTITLE"; public static final String TICKER_TEXT = "ALARM_TICKER"; public static final String NOTIFICATION_ID = "NOTIFICATION_ID"; /* Contains time in 24hour format 'HH:mm' eg '04:30' or '18:23' */ public static final String HOUR_OF_DAY = "HOUR_OF_DAY"; public static final String MINUTE = "MINUTES"; @Override public void onReceive(Context context, Intent intent) { Log.d("AlarmReceiver", "AlarmReceiver invoked!"); final Bundle bundle = intent.getExtras(); final Object systemService = context.getSystemService(Context.NOTIFICATION_SERVICE); // Retrieve notification details from the intent final String tickerText = bundle.getString(TICKER_TEXT); final String notificationTitle = bundle.getString(TITLE); final String notificationSubText = bundle.getString(SUBTITLE); int notificationId = 0; try { notificationId = Integer.parseInt(bundle.getString(NOTIFICATION_ID)); } catch (Exception e) { Log.d("AlarmReceiver", "Unable to process alarm with id: " + bundle.getString(NOTIFICATION_ID)); } Calendar currentCal = Calendar.getInstance(); int alarmHour = bundle.getInt(HOUR_OF_DAY); int alarmMin = bundle.getInt(MINUTE); int currentHour = currentCal.get(Calendar.HOUR_OF_DAY); int currentMin = currentCal.get(Calendar.MINUTE); if (currentHour != alarmHour && currentMin != alarmMin) { /* * If you set a repeating alarm at 11:00 in the morning and it * should trigger every morning at 08:00 o'clock, it will * immediately fire. Eg Android tries to make up for the * 'forgotten' reminder for that day. Therefore we ignore the event * if Android tries to 'catch up'. */ Log.d(LocalNotification.PLUGIN_NAME, "AlarmReceiver, ignoring alarm since it is due"); return; } // Construct the notification and notificationManager objects final NotificationManager notificationMgr = (NotificationManager) systemService; final Notification notification = new Notification(R.drawable.ic_launcher, tickerText, System.currentTimeMillis()); final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(), 0); notification.defaults |= Notification.DEFAULT_SOUND; notification.vibrate = new long[] { 0, 100, 200, 300 }; notification.setLatestEventInfo(context, notificationTitle, notificationSubText, contentIntent); /* * If you want all reminders to stay in the notification bar, you should * generate a random ID. If you want do replace an existing * notification, make sure the ID below matches the ID that you store in * the alarm intent. */ notificationMgr.notify(notificationId, notification); } } 

Mi archivo de manifiesto de Android:

 <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_VIDEO"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:configChanges="orientation|keyboardHidden" android:name=".MyPhoneGapActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name="com.phonegap.plugin.localnotification.AlarmReceiver" > </receiver> <receiver android:name="com.phonegap.plugin.localnotification.AlarmRestoreOnBoot" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application> 

  • Los complementos no siempre se agregan después de cordova añadir plataforma android and iOs
  • Cómo establecer la posición de spinner con cordova
  • ¿Cuál es la diferencia entre un plugin PhoneGap y addJavascriptInterface?
  • Cordova / PhoneGap Plugin Desarrollo de flujo de trabajo para Android
  • Captura de firma en PhoneGap
  • PhoneGap: Cómo hacer que los enlaces de iframes se abran en InAppBrowser
  • Agregar complementos de Cordova / Phonegap detrás de un proxy
  • gap_init llamado de origen restringido
  • Cordova Android status Bar configurado para transparente
  • Acceder al almacenamiento interno de android con cordova file plugin
  • La velocidad es "nula" con el complemento de geolocalización en Android 5+
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.