Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed force_show_in_foreground parameter when set to false #49

Merged

Conversation

Jei
Copy link
Contributor

@Jei Jei commented Jan 31, 2019

This PR fixes a bug that prevents data notifications from being shown with the app closed or in background, when sending the force_show_in_foreground parameter as false.

Push notification test code:

<?php $url = 'https://fcm.googleapis.com/fcm/send';

	$fields = array (
			'to' => "<FCM TOKEN>",
			'data' => array(
				"test1" => "value1",
				"test2" => "value2",
				"timestamp"=>date('Y-m-d G:i:s'),
				"title" => "title",
				"message" => "message",
				"big_text"=>"big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text big text even more text ",
				"big_text_summary"=>"big_text_summary",
				"icon" => "http://via.placeholder.com/150x150",
				"image" => "http://via.placeholder.com/350x150",	// won't show the big_text
				"force_show_in_foreground"=> false,
				"color" => "#ff6600",
				"channelId" => "default"	// or a different channel
			)
	);

	$headers = array (
			'Authorization: key=<SERVER KEY>',
			'Content-Type: application/json'
	);

	$ch = curl_init ();
	curl_setopt ( $ch, CURLOPT_URL, $url );
	curl_setopt ( $ch, CURLOPT_POST, true );
	curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
	curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
	curl_setopt ( $ch, CURLOPT_POSTFIELDS, json_encode($fields));

	$result = curl_exec ( $ch );
	echo $result."\n";
	curl_close ( $ch );
?>

@hansemannn hansemannn requested a review from m1ga January 31, 2019 17:01
@m1ga
Copy link
Collaborator

m1ga commented Feb 2, 2019

before:

  • no notification when app is in background and force_show_in_foreground is set

after PR:

  • notification is shown when app is in background and force_show_in_foreground is set

When app is in foreground it behaves as expected too

Ready to merge!

@hansemannn hansemannn merged commit 3ce5abc into hansemannn:master Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants