Comments (6)
Below is my class. I did initially try and get this using working Guzzle but I failed miserably and as time was a huge constraint, I send a manual CURL command via the command line. I guess you want to tidy that up and if you do, using Guzzle, please send me the Guzzle code you use
Ste,
`
class AndroidController extends MobileDevicePushNotificationController
{
protected $apiEndpoint = 'https://fcm.googleapis.com/fcm/send';
protected $serverKey;
/**
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->serverKey = $this->container->getParameter('fcm_server_key');
}
public function send()
{
foreach ($this->getUserDeviceTokens($this->getUser()) as $deviceToken) {
$body = $this->getBody();
$body['to'] = (string) $deviceToken;
$body['priority'] = (int) $this->getPriority();
$body = addcslashes(
json_encode(
$body
),
'"'
);
$curl_string = <<<CURLSTRING
curl -X POST --header "Authorization: key=$this->serverKey" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "$body"
CURLSTRING;
// Manually run CuRL command from the command line :(
$responseBody = json_decode(exec($curl_string), 1);
// Check response from FCM to see if we need to remove any deregistered tokens from our database
if (array_key_exists('results', $responseBody)) {
foreach ($responseBody['results'] as $result) {
if (array_key_exists('error', $result)) {
if ($result['error'] == 'InvalidRegistration') {
$this->removeTokenFromDatabase($deviceToken);
}
}
}
}
}
}
public function removeTokenFromDatabase($token)
{
$deviceToken = $this->getObjectManager()->getRepository('MyBundle:MobileDeviceToken')->findBy([
'user' => $this->getUser(),
'token' => $token
]);
foreach ($deviceToken as $token) {
$this->getObjectManager()->remove($token);
}
$this->getObjectManager()->flush();
}
}`
from rmspushnotificationsbundle.
Is there any update on it ?
from rmspushnotificationsbundle.
Any update on this?
from rmspushnotificationsbundle.
@Hasib-rafi1 @jkosmetos - I wrote my own FCM code in the end. I can share that script with you if you like?
from rmspushnotificationsbundle.
@sterichards - That would be great, thanks man!
from rmspushnotificationsbundle.
Is this bundle maintained yet? Anyone knows another similar package that is?
from rmspushnotificationsbundle.
Related Issues (20)
- How to set title on iOS Push message? HOT 2
- Cannot send localized notifications HOT 1
- Support for Firebase Cloud Messaging HOT 7
- unpack() in AppleNotificaion produces a notice HOT 1
- Is this project still maintained ? HOT 1
- Notify IOS Devices Via GCM
- FCN Notifications trouble HOT 1
- Android GCM :: How to detect the need to remove the DeviceToken/DeviceRegId from my database with the bundle? HOT 2
- Support for Web Push Notifications? HOT 1
- Bundle maintained and manage Firebase message HOT 4
- Support for APN Auth Key
- Response null when sending an Android push notification
- app.ERROR: {"command":8,"status":7,"identifier":0} HOT 1
- Breaks with Buzz v0.17.x HOT 7
- Send within doctrine.onFlush listener
- Command rms:test-push is not available in Symfony>=4
- [app] {"command":8,"status":8,"identifier":0}
- Issues with objects in Android Notifications
- Apple HTTP/2 APNS -- push notification support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rmspushnotificationsbundle.