1

現在、FCMを使用したアンドロイドアプリを構築しています。残念ながら、私はこれをすべてまとめることはできません。 firebaseをアプリケーションに正常に接続しました.jsonファイル(APIプロバイダによって生成されたファイル)も適切に配置されています。 appがフォアグラウンドにある場合、onMessagReceivedが適切に呼び出されます。プッシュ通知も適切に受信されますが、通知時のクリックイベント(バックグラウンド中)はまったく何も行いません。起動アクティビティを開かずに通知が消えます。サンプルのFCMアプリケーションで.jsonファイルを私が生成したものに切り替えると、通知を希望の方法でクリックします。私は何が起こっているのか分かりません。私はランチャー活動/ FCMサービスと私のAPIプロバイダによって生成された.jsonファイルと私のAndroidManifest.xmlの一部を提示下Androidのプッシュ通知でアプリが開かれない

(一部のデータが変更されたが、特定の値が等しい):

<application 
    android:name=".xyz" 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/xyz" 
    android:roundIcon="@mipmap/ic_launcher" 
    android:theme="@style/Theme.xyz.Light.DarkActionBar"> 
    <activity 
     android:name=".views.activities.SplashActivity" 
     android:screenOrientation="portrait" 
     android:theme="@style/Theme.xyz.Splash"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW"/> 

      <category android:name="android.intent.category.DEFAULT"/> 
      <category android:name="android.intent.category.BROWSABLE"/> 

      <data 
       android:host="xyz.com" 
       android:pathPrefix="/api,xyz" 
       android:scheme="https"/> 
      <data 
       android:host="xyz.pl" 
       android:pathPrefix="/api,xzz" 
       android:scheme="https"/> 
     </intent-filter> 
    </activity> 

    ... 

    <service android:name=".services.xyzFirebaseMessagingService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.MESSAGING_EVENT"/> 
     </intent-filter> 
    </service> 
    <service android:name=".services.xyzFirebaseInstanceService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> 
     </intent-filter> 
    </service> 

    </activity> 

</application> 

{ 
    "project_info": { 
    "project_number": "123456789123", 
    "firebase_url": "https://xxx.firebaseio.com", 
    "project_id": "xxx", 
    "storage_bucket": "xxx.appspot.com" 
    }, 
    "client": [ 
    { 
     "client_info": { 
     "mobilesdk_app_id": "1:123456789123:android:a12a3456789012e1", 
     "android_client_info": { 
      "package_name": "com.mycompany.myapp" 
     } 
     }, 
     "oauth_client": [ 
     { 
      "client_id": "123456789123-zzz.apps.googleusercontent.com", 
      "client_type": 3 
     } 
     ], 
     "api_key": [ 
     { 
      "current_key": "current_key" 
     } 
     ], 
     "services": { 
     "analytics_service": { 
      "status": 1 
     }, 
     "appinvite_service": { 
      "status": 1, 
      "other_platform_oauth_client": [] 
     }, 
     "ads_service": { 
      "status": 2 
     } 
     } 
    } 
    ], 
    "configuration_version": "1" 
} 

また、私のAPIプロバイダによって生成されたサンプルfcmメッセージも含まれています。

[2017-11-02 12:10:06] https://fcm.googleapis.com/fcm/send 
HEADERS: [ 
    "Authorization:key=my_auth_key" 
] 
DATA: { 
    "notification": { 
     "icon": "https://www.myavatar.com/avatar.png", 
     "title": "Message title", 
     "body": "aaa", 
     "click_action": "https://www.app.com/notifications,open?_id=678696787lkju82" 
    }, 
    "data": { 
     "date_create": "2017-11-02 12:10:04", 
     "sender_type": "user", 
     "sender_app_id": "2", 
     "sender_app_display": "MyApp", 
     "sender_user_id": "43", 
     "sender_display": "WK", 
     "type": "message" 
    }, 
    "to": "fYqHDJEVUUM:APAasdasdasdHS_GOsen-kkjghkasjhd898098klj-8797hoijo8" 
} 
RESPONSE: { 
    "multicast_id": 556579726904--2753, 
    "success": 1, 
    "failure": 0, 
    "canonical_ids": 0, 
    "results": [ 
     { 
      "message_id": "0:1880938748%hkk4bjl2k1" 
     } 
    ] 
} 

解消。私は、 "click_action"パラメータが問題を引き起こしていることを発見しました。私のAPIプロバイダは、このパラメータの値としてurlアドレスを設定して、Web側で自分自身を助けるためにそれを行いました;)@ Barns52のおかげで、

+0

異なるメッセージペイロードに関するFirebaseのドキュメントをお読みください。 FCMは2つの異なるペイロードを提供します。アプリがバックグラウンドにあるときは、各ペイロードタイプが異なる方法で処理されます。 – Barns

+0

以前にドキュメントを読んでいないと、私は新しいトピックを作成しません。 「あなたのアプリがバックグラウンドにあるときに通知メッセージが届いています。この場合、通知はデバイスのシステムトレイに配信されます。通知をタップすると、デフォルトでアプリランチャーが開きます。私のAPIプロバイダは私に通知メッセージを送信し、トレイ上の通知をクリックすることは何もしません。 –

+0

この場合、メッセージの生成に使用するコードとメッセージの受信に使用するコードを送信する必要があります。 'AndroidManifest'を投稿するだけで、あなたがした間違いを診断することができません。 – Barns

答えて

0

アクティビティを明示的に呼び出す必要があります。

関連する問題