sheena2994

Untitled

Dec 15th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. // FCM
  2. $optionBuiler = new OptionsBuilder();
  3. $optionBuiler->setTimeToLive(60*20);
  4.  
  5. $notificationBuilder = new PayloadNotificationBuilder($title);
  6. $notificationBuilder->setTitle($title)
  7. ->setBody($s_msg)
  8. // ->setSound('sound')
  9. ->setBadge($badge);
  10.  
  11. $dataBuilder = new PayloadDataBuilder();
  12. $dataBuilder->addData([ 'u' => $user_id1,
  13. 'i' => $item_id,
  14. 't' => $trade_id,
  15. 'm' => $message_id,
  16. 's_msg' => $s_msg,
  17. 'type' => $type,
  18. 'badge' => $badge
  19. ]);
  20.  
  21.  
  22. $option = $optionBuiler->build();
  23. $notification = $notificationBuilder->build();
  24. $data = $dataBuilder->build();
  25.  
  26. // $token = $user_data->device_token_android;
  27.  
  28. $downstreamResponse = FCM::sendTo($device_token_android, $option, null, $data);
  29.  
  30. $downstreamResponse->numberSuccess();
  31. $downstreamResponse->numberFailure();
  32. $downstreamResponse->numberModification();
  33.  
  34. //return Array - you must remove all this tokens in your database
  35. $downstreamResponse->tokensToDelete();
  36.  
  37. //return Array (key : oldToken, value : new token - you must change the token in your database )
  38. $downstreamResponse->tokensToModify();
  39.  
  40. //return Array - you should try to resend the message to the tokens in the array
  41. $downstreamResponse->tokensToRetry();
Add Comment
Please, Sign In to add comment