sheena2994

Untitled

Aug 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. public static function sendPushNotification($users_id1, $users_id2, $name1, $posts_id, $message_id, $title, $s_msg, $device_token, $type, $badge) {
  3.  
  4. $optionBuiler = new OptionsBuilder();
  5. $optionBuiler->setTimeToLive(60*20);
  6. $optionBuiler->setPriority('high');
  7.  
  8.  
  9. $notificationBuilder = new PayloadNotificationBuilder($title);
  10. $notificationBuilder->setBody($s_msg)->setSound('default');
  11.  
  12. $badge=11;
  13. $dataBuilder = new PayloadDataBuilder();
  14. $dataBuilder->addData([ 'u' => $users_id1,
  15. 'name' => $name1,
  16. 'p' => $posts_id,
  17. 'm' => $message_id,
  18. 's_msg' => $s_msg,
  19. 'type' => $type,
  20. 'badge' => $badge
  21. ]);
  22.  
  23. $option = $optionBuiler->build();
  24. $notification = $notificationBuilder->build();
  25. $data = $dataBuilder->build();
  26. $downstreamResponse = FCM::sendTo($device_token, $option, $notification, $data);
  27.  
  28. return 1;
  29. // return new JsonResponse(array('status'=>'1','sucess'=>$downstreamResponse->numberSuccess(),'fail'=> $downstreamResponse->numberFailure(),'msg'=>$downstreamResponse->tokensWithError()),200);
  30. }
Add Comment
Please, Sign In to add comment