Giter Site home page Giter Site logo

Comments (8)

andrehtissot avatar andrehtissot commented on June 3, 2024

I'm assuming you are referring to Android.

Do you also get twice the payload when app is on the foreground when the device receive the push?

from cordova-plugin-fcm-with-dependecy-updated.

Suryalg avatar Suryalg commented on June 3, 2024

I'm assuming you are referring to Android.

Do you also get twice the payload when app is on the foreground when the device receive the push?

Yes for android only.
When in foreground it receives notification on JS callback only. Not in tray which is fine.
Only issue is in Background or in closed state.
P.S how will I know if I am getting twice the payload.

This is the code I am using to send
$token='*****';
$title='xc Welcome to My Masjid';
$body = "This is a test notification";
$serverkeyValue = "****";

	$ch           = curl_init("https://fcm.googleapis.com/fcm/send"); 
	
	$notification = array(
		'title' => $title,
		'body' => $body,
		'priority' => 'high',
		'sound' => 'sound',
		'vibration' => 'yes'
	);
	
	$data = array(
    'title' => $title,
    'body' => $body,
    'sound' => 'sound',
    "param1"=>"value1" ,
    "param2"=>"value2"  
  ); 
	
	
	$arrayToSend  = array(
		'to' => $token,
		'priority'=>"high",
		'notification' => $notification,
		'data' => $data
	);
	$json         = json_encode($arrayToSend);
	$headers      = array();
	$headers[]    = 'Content-Type: application/json';
	$headers[]    = 'Authorization: key= ' . $serverkeyValue;
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_exec($ch);
	
	$response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
	
	//echopredie($response); 
	if($response==200 || $response=='200')
	{
		dd('succ');
	}
	return $response;

from cordova-plugin-fcm-with-dependecy-updated.

andrehtissot avatar andrehtissot commented on June 3, 2024

Let's say you have in your app runs something like this:

FCMPlugin.onNotification(function(data){
  console.log(Date.now()+": "+JSON.stringify(data));
});

When the app is on the foreground and the device receives the push, do you receive the console message twice?

from cordova-plugin-fcm-with-dependecy-updated.

Suryalg avatar Suryalg commented on June 3, 2024

Let's say you have in your app runs something like this:

FCMPlugin.onNotification(function(data){
  console.log(Date.now()+": "+JSON.stringify(data));
});

When the app is on the foreground and the device receives the push, do you receive the console message twice?

Yes absolutely I am getting console.log twice on js callback of onNotification

from cordova-plugin-fcm-with-dependecy-updated.

andrehtissot avatar andrehtissot commented on June 3, 2024

So, it's clear that the issue is on the sender side.
Could you check if the php code you presented above is not being executed twice for each device's firebase token?

from cordova-plugin-fcm-with-dependecy-updated.

Suryalg avatar Suryalg commented on June 3, 2024

So, it's clear that the issue is on the sender side.
Could you check if the php code you presented above is not being executed twice for each device's firebase token?

I have attached the PHP code to send notification on above. can you help me on that?

from cordova-plugin-fcm-with-dependecy-updated.

andrehtissot avatar andrehtissot commented on June 3, 2024

The code seems fine at a glance.
My question is more about how you execute it.
Do you manually run this php file or is it triggered by another application?

from cordova-plugin-fcm-with-dependecy-updated.

andrehtissot avatar andrehtissot commented on June 3, 2024

Issue closed due to inactivity.

from cordova-plugin-fcm-with-dependecy-updated.

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.