2017-10-09 5 views
0
  • PhoneGapの-プラグインプッシュ
  • イオン性フレームワーク:3.6.0
  • イオンのAppスクリプト:2.1.4
  • 角度コア:4.1.3
  • 角度コンパイラCLI:4.1.3
  • ノード:6.11.1
  • OSプラットフォーム:Windowsの10
  • ナビゲータープラットフォーム:Win32の
  • ユーザエージェント:Mozilla/5.0(Windows NT 10.0; Win64; x64の) のAppleWebKit/537.36(KHTML、ヤモリなど)クローム/ 60.0.3112.113 サファリ/アプリがあるとき、537.36アプリが&が通知を受け取る開いているときにそれは完璧に動作イオン3アプリケーションは、通知をクリック上の特定のページにリダイレクトされていない

    は、それが自動的に特定のpage.Butにリダイレクト閉じる&通知をクリックすると、ページにリダイレクトされません。アプリを起動するだけです。

pushObject通知コードの

pushObject.on('notification').subscribe((notification: any) => { 
     console.log('Received a notification', notification); 
     if(notification.additionalData.type=="news"){ 
     this.NewsAndEventsDetails(notification.additionalData.type_id); 
     }else if(notification.additionalData.type=="notice"){ 
     this.getNoticesSingle(notification.additionalData.type_id); 
     }else if(notification.additionalData.type=="bill"){ 
     this.getBillsSingle(notification.additionalData.type_id); 
     }else{ 
     let prompt = this.alertCtrl.create({ 
      title: notification.title, 
      message: notification.message 
     }); 
     prompt.present(); 
     } 
    }); 

答えて

0

私の側からは、同じ問題は、私は次のステップを行って、この問題を解決し、

を発生します。

Install FCM plugin 

ionic cordova plugin add cordova-plugin-fcm 

npm install --save @ionic-native/fcm 

Get google-services.json file GoogleService-Info.plist file from fcm for your registered project. 

Add google-services.json in android platform root like /platforms/android/google-services.json 


Add GoogleService-Info.plist file in ios platform like /patforms/ios/ProjectName/Resoures/Resoures/GoogleService-Info.plist 
or also add at /platforms/android/GoogleService-Info.plist 

Now run the project on android and ios device you get fcmid. 
Store fcmid to the server. 

Server side code is like this. 


public function sendNotification($sectionName){ 
     $url = 'https://fcm.googleapis.com/fcm/send'; 
     $fields = array (
       'to' => "fcmId", 
       'notification' => array (
         "body" => "Hello test", 
         "title" => "Title", 
         "icon" => "myicon", 
         "sound" => "default", 
         "click_action" => "FCM_PLUGIN_ACTIVITY", // this is important for ontapped 
       ), 
       'data' => array('rollno' => "test", 
           'name' => "manish", 
           'activitySection' => $sectionName), 
           'priority' => 'high', 
     ); 
     $fields = json_encode ($fields); 
     echo $fields; 
      $headers = array (
        'Authorization: key=' . "fcm server key", 
        'Content-Type: application/json' 
      ); 

     $ch = curl_init(); 
     curl_setopt ($ch, CURLOPT_URL, $url); 
     curl_setopt ($ch, CURLOPT_POST, true); 
     curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
     curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields); 

     $result = curl_exec ($ch); 
     curl_close ($ch); 
    } 

This is on app 


fcmInitilization() { 
    if (!this.plt.is('cordova')) { 
     console.warn('Push notifications not initialized. Cordova is not available - Run in physical device'); 
     return; 
    } 
    this.fcm.onNotification().subscribe(data => { 
     if (data.wasTapped) { 
     // do onTapped work here means app in background 
     } else { 
     let confirmAlert = this.alertCtrl.create({ 
      title: 'New Notification', 
      message: data.title, 
      buttons: [{ 
      text: 'Ignore', 
      role: 'cancel' 
      }, { 
      text: 'View', 
      handler:() => { 
       //TODO: Your logic here 
      } 
      }] 
     }); 
     confirmAlert.present(); 
     }; 
    }) 
    } 
+0

あなたの返信のためのThnaks。私はcordova-plugin-fcmを使用していません。私はphonegap-plugin-pushを使用しています。 –

+0

こんにちは、https://github.com/phonegap/phonegap-plugin-push タップされたデータが来るかどうかチェックしてください。 これらのコードをサーバー側に追加しない場合。 "data" =>配列( "タイトル" => 'テストプッシュ'、 "メッセージ" => '"info" = "スーパー秘密情報"、 "content-available" = > '1') – Manish

関連する問題