La aplicación de Android aparece cuando se recibe una notificación de envío de GCM en el dispositivo
Quiero implementar una aplicación emergente al recibir la notificación de gcm o el mensaje del servidor. Generalmente un servidor envía un mensaje a api de GCM y desde allí el mensaje se envía al cliente.
En el lado del cliente generalmente obtienes una notificación pero no quiero que quiera que el dispositivo cliente active o abra o inicie esa aplicación en particular.
- Notificación GCM no recibida en uno de los dispositivos móviles
- Mensajería en la nube de Google, devolviendo 401 no autorizado
- ¿Pueden los mensajes de la nube de firebase ser detectados por la aplicación en segundo plano?
- Cómo obtener el token del dispositivo
- Notificación push en android usando diácono
¿Es posible? ¿si es así, cómo?
la siguiente es mi función de generación de notificaciones
private static void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MainActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; // Play default notification sound notification.defaults |= Notification.DEFAULT_SOUND; // Vibrate if vibrate is enabled notification.defaults |= Notification.DEFAULT_VIBRATE; notificationManager.notify(0, notification); }
y si esta pregunta ya se le pide a algún lugar amablemente redireccionarme y borrar mi pregunta.
Gracias por adelantado.
- ¿En qué período cambia el token de aplicación del firebase y cómo se administra?
- cordova fcm plugin en Android data.wasTapped no funciona
- Android: Error com.parse.ParseException: se debe especificar al menos un campo ID (installationId, deviceToken) en esta operación
- Añadir acción a la notificación Firebase
- Mostrar notificación de inserción en el cuadro de alerta cuando la aplicación se está ejecutando en primer plano
- ¿El mensaje de GCM se está reemplazando?
- Android y (millones de) notificaciones push
- Registrar GCM de un proyecto de biblioteca
Si no desea recibir una notificación, el código no debería crear una notificación. En lugar de llamar a generateNotification
llama a un método que inicia la Activity
principal de tu aplicación (o cualquier Activity
que quieras iniciar tu aplicación).
Intent intent = new Intent().setClass(context, MainActivity.class); startActivity(intent);
Si he entendido correctamente, lo que quieres es iniciar la aplicación directamente en lugar de crear la notificación.
Para hacer eso solo necesita reemplazar la llamada a generateNotification () con este código:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("your.package.name"); startActivity(LaunchIntent);
Es eso lo que necesita?
- Actualizar ExpandableListView desde mi adaptador
- La imagen transparente aparece en negro en un mapa de bits en caché