Code Monkey home page Code Monkey logo

Comments (2)

 avatar commented on August 17, 2024 1

Hey guys,

I found a way to make it work for now, hope it helps someone.
I know is now the best way but it can make it until Rich or someone more experienced answer the issue.
First i changed the config property use_multi_curl to false.
Then your code can look like the sample bellow:

if($platform == 'gcm') {
$pushResponses = $pushNotificationService->getResponses('rms_push_notifications.os.android.gcm');
$pushResponse = (isset($pushResponses[0])?$pushResponses[0]:'');
if($pushResponse) {
$pushResponseContent = $pushResponse->getContent();
if(strpos($pushResponseContent, 'NotRegistered') !== false) {
//Remove the token from your database here
}
}
}

from rmspushnotificationsbundle.

dueddel avatar dueddel commented on August 17, 2024

@GuilhermeMoura1 Thanks for the snippet. With that one I came up to the following implementation for checking the response in general (not only for "NotRegistered"). This is just an action method in one of my controllers I have been using to test the push services (I just post this here in case of anyone is interested):

/**
 * @Route("/push-test")
 *
 * @return \Symfony\Component\HttpFoundation\JsonResponse
 */
public function pushTestAction() {
	//	… use RMS here to send push notifications

	//	now get the response for android similar to the code above by GuilhermeMoura1

	/** @var Response[] $pushResponses */
	$pushResponses = $this->get('rms_push_notifications')->getResponses('rms_push_notifications.os.android.gcm');
	$responses = [];

	foreach ($pushResponses as $pushResponse) {
		//	this is a JSON string
		$responseContent = $pushResponse->getContent();
		//	let's decode it
		$responseData = json_decode($responseContent, true);
		//	add to list of responses
		$responses[] = $responseData;
	}

	return $this->json([
		'respones' => $responses,
	]);
}

from rmspushnotificationsbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.