Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FCM
- $optionBuiler = new OptionsBuilder();
- $optionBuiler->setTimeToLive(60*20);
- $notificationBuilder = new PayloadNotificationBuilder($title);
- $notificationBuilder->setTitle($title)
- ->setBody($s_msg)
- // ->setSound('sound')
- ->setBadge($badge);
- $dataBuilder = new PayloadDataBuilder();
- $dataBuilder->addData([ 'u' => $user_id1,
- 'i' => $item_id,
- 't' => $trade_id,
- 'm' => $message_id,
- 's_msg' => $s_msg,
- 'type' => $type,
- 'badge' => $badge
- ]);
- $option = $optionBuiler->build();
- $notification = $notificationBuilder->build();
- $data = $dataBuilder->build();
- // $token = $user_data->device_token_android;
- $downstreamResponse = FCM::sendTo($device_token_android, $option, null, $data);
- $downstreamResponse->numberSuccess();
- $downstreamResponse->numberFailure();
- $downstreamResponse->numberModification();
- //return Array - you must remove all this tokens in your database
- $downstreamResponse->tokensToDelete();
- //return Array (key : oldToken, value : new token - you must change the token in your database )
- $downstreamResponse->tokensToModify();
- //return Array - you should try to resend the message to the tokens in the array
- $downstreamResponse->tokensToRetry();
- // return Array (key:token, value:errror) - in production you should remove from your database the tokens
- return 1;
Add Comment
Please, Sign In to add comment