-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from xTeamTEICM/dev
Dev
- Loading branch information
Showing
38 changed files
with
1,019 additions
and
5,854 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...p/Controllers/AuthApi/LoginController.php → ...Http/Controllers/Auth/LoginController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ontrollers/AuthApi/RegisterController.php → ...p/Controllers/Auth/RegisterController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\User; | ||
use Illuminate\Http\Request; | ||
|
||
class deviceTokenController extends Controller | ||
{ | ||
public function setDeviceToken(Request $request) | ||
{ | ||
$this->validate($request, [ | ||
'deviceToken' => 'required|String', | ||
]); | ||
|
||
$id = auth('api')->user()->id; | ||
User::query() | ||
->where("id", "=", $id) | ||
->update(['deviceToken' => request('deviceToken')]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
|
||
use LaravelFCM\Facades\FCM; | ||
use LaravelFCM\Message\OptionsBuilder; | ||
use LaravelFCM\Message\PayloadDataBuilder; | ||
use LaravelFCM\Message\PayloadNotificationBuilder; | ||
|
||
class FCMController extends Controller | ||
{ | ||
public function sentToOne($userToken, $Title, $Body, $Data, $ClickAction) | ||
{ | ||
$optionBuilder = new OptionsBuilder(); | ||
$optionBuilder->setTimeToLive(60 * 20); | ||
|
||
$notificationBuilder = new PayloadNotificationBuilder($Title); | ||
$notificationBuilder->setBody($Body)->setSound('default')->setClickAction($ClickAction); | ||
|
||
$dataBuilder = new PayloadDataBuilder(); | ||
$dataBuilder->addData($Data); | ||
|
||
$option = $optionBuilder->build(); | ||
$notification = $notificationBuilder->build(); | ||
$data = $dataBuilder->build(); | ||
|
||
$downstreamResponse = FCM::sendTo($userToken, $option, $notification, $data); | ||
|
||
//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(); | ||
} | ||
|
||
public function sentToMultiple($userTokens, $Title, $Body, $Data, $ClickAction) | ||
{ | ||
$optionBuilder = new OptionsBuilder(); | ||
$optionBuilder->setTimeToLive(60 * 20); | ||
|
||
$notificationBuilder = new PayloadNotificationBuilder($Title); | ||
$notificationBuilder->setBody($Body)->setSound('default')->setClickAction($ClickAction); | ||
|
||
$dataBuilder = new PayloadDataBuilder(); | ||
$dataBuilder->addData($Data); | ||
|
||
$option = $optionBuilder->build(); | ||
$notification = $notificationBuilder->build(); | ||
$data = $dataBuilder->build(); | ||
|
||
$downstreamResponse = FCM::sendTo($userTokens, $option, $notification, $data); | ||
|
||
//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(); | ||
} | ||
} |
Oops, something went wrong.