좋아, 여기 내 문제가있다. 푸시 알림을 수신하는 Service
이 있습니다. 이제 푸시 알림의 내용에 따라 해당 애플리케이션을 클릭해야 시작됩니다.서비스에서 응용 프로그램 시작
푸시 알림을 수신하거나 서비스를 사용하는 데 아무런 문제가 없습니다. 작동하지 못하는 유일한 방법은 올바른 애플리케이션을 여는 부분입니다.
Service
에서 신청서를 열려면 무엇을해야합니까? 이 서비스와 함께 작동하는 여러 개의 앱이 있기 때문에 이것은 동적으로 이루어져야합니다.
누군가 올바른 방향으로 나를 가리킬 수 있다면 좋을 것입니다.
추신. 도서관에 보관하는 GCM 서비스를 사용하고 있으므로 여러 앱에서 사용할 수 있습니다. 이것은 내가 URL의 내용을 확인하고 알림에 대한 올바른 의도를 설정해야하는 GCMIntentService.onMessage()
기능입니다 :
@Override
protected void onMessage(Context arg0, Intent arg1)
{
Log.i(TAG, "new message = " + arg1.getExtras());
//Get a reference to the NotificationManager
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
//Instantiate the Notification
int icon = getResourseIdByName(arg0.getApplicationContext().getPackageName(), "drawable", "notification_icon");
CharSequence tickerText = arg1.getExtras().getString("tickertext");
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
//Define the notification's message and PendingIntent
Context context = getApplicationContext();
CharSequence contentTitle = arg1.getExtras().getString("contentTitle");
CharSequence contentText = arg1.getExtras().getString("contentText");
Intent notificationIntent = null;
if(arg1.getExtras().getString("url").isEmpty())
{
notificationIntent = new Intent(this, arg1.getExtras().getString("packageName").getClass());
}
else
{
notificationIntent = new Intent(this, MyWebView.class);
}
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
//Pass the Notification to the NotificationManager
int notificationId = Integer.parseInt(arg1.getExtras().getString("notificationId"));
mNotificationManager.notify(notificationId, notification);
}
시도했지만 작동하지 않습니다. – DijkeMark
지금 사용합니다 : notificationIntent = arg0 – DijkeMark