2017-09-16 10 views
-1

フルメソッドのシグネチャは...私が行うことができるようにしたいどのようなiOSのdidReceiveRemoteNotificationのAndroid対応版は何ですか?

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) 

は、プッシュ通知が届いたときに、デバイスの応答を持っているです。たとえば、特定の画面に自動的にナビゲートして、通知で特定されたデータを表示することがあります。

+1

を参照してくださいIあなたがしようとしていることを説明してくれればもっと助かります。 – Tharkius

+0

質問を更新しました。 –

答えて

0

Androidの同等のメソッドは、参考のためonMessageReceived ます。public void(RemoteMessage remoteMessage)

@Override 
public void onMessageReceived(RemoteMessage remoteMessage) { 
    // ... 

    // TODO(developer): Handle FCM messages here. 
    Log.d(TAG, "From: " + remoteMessage.getFrom()); 

    // Check if message contains a data payload. 
    if (remoteMessage.getData().size() > 0) { 
     Log.d(TAG, "Message data payload: " + remoteMessage.getData()); 

     if (/* Check if data needs to be processed by long running job */ true) { 
      // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher. 
      scheduleJob(); 
     } else { 
      // Handle message within 10 seconds 
      handleNow(); 
     } 

    } 

    // Check if message contains a notification payload. 
    if (remoteMessage.getNotification() != null) { 
     Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); 
    } 

    // Also if you intend on generating your own notifications as a result of a received FCM 
    // message, here is where that should be initiated. See sendNotification method below. 
} 

ある12

0

PackageManager.getLaunchIntentForPackageはあなたが探しているものです。

これは、あなたがそれを使用したい方法です: -

Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); 
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(launchIntent); 
関連する問題