How to implement firebase push notification in android and iphone
If you need to send a Firebase notification using PHP, then simply use these tutorials, which can help you send the notification to Android and iPhone devices. Basically there is a GCM (Google Cloud Messaging), which is sending the notification, but now Google has launched Firebase Cloud Messaging (FCM).
Step 1)
Generate the Firebase Server Key. For this you need to follow the below steps.
- Log in to the Firebase Developer Console, and if you haven’t created a project yet, click “Create Project.”
- Enter a project name, accept the Firebase terms, and press “CREATE PROJECT.”
- Does it set up Google Analytics for your project? Select “Not Right Now” and press “CREATE PROJECT.”
- The project will be created, and you will get the message “Your new project is ready.” Press the “Continue” button to redirect to your project dashboard page.
- On the dashboard page, click the gear icon in the top left and select “Project settings.”
- Go to the “Cloud Messaging Section” section, and you will have the server key.
- Done! I hope you successfully generate a Firebase server key.
Step 2)
Create a file named fcm.php and add the below push notification PHP code. Be sure to replace the Your Firebase Server API Key Here with a proper one from the Google API’s Console page.
<?php
class FCM {
function __construct() {
}
/**
* Sending Push Notification
*/
public function send_notification($registatoin_ids, $notification,$device_type) {
$url = 'https://fcm.googleapis.com/fcm/send';
if($device_type == "Android"){
$fields = array(
'to' => $registatoin_ids,
'data' => $notification
);
} else {
$fields = array(
'to' => $registatoin_ids,
'notification' => $notification
);
}
// Firebase API Key
$headers = array('Authorization:key=Your Firebase
Server API Key Here','Content-Type:application/json');
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
}
}
?>
Step 3)
Finally, create an index.php and add the below code. Before testing, please replace your device token with your real device token.
<?php
$regId ="Your Device Token";
// INCLUDE YOUR FCM FILE
include_once 'fcm.php';
$notification = array();
$arrNotification= array();
$arrData = array();
$arrNotification["body"] ="Test by Ravi Sukhadia.";
$arrNotification["title"] = "TECHIBUCKET";
$arrNotification["sound"] = "default";
$arrNotification["type"] = 1;
$fcm = new FCM();
$result = $fcm->send_notification($regId, $arrNotification,"Android");
?>
Step 4)
Send Push Notification to iOS Using PHP. You just need to change “Android” to “IOS” in your index.php file. like below…
FOR ANDROID
$result=$fcm->send_notification($regId,$arrNotification,"Android");
FOR IPHONE
$result=$fcm->send_notification($regId, $arrNotification,"IOS");
Step 5)
Now run your index.php file, and you can get the notification on your devices.
Been messing around on Craybet for about six weeks or so and thought I’d throw out what I think since I haven’t seen many posts about it in this forum. Signed up on a whim and signing up literally took two minutes. Minimum deposit is $10 and that’s pretty standard. I grabbed a welcome bonus — matched my first deposit 100% up to 500 and 50 free spins on Gates of Olympus. Wagering was 35x and that is kinda average but it’s manageable.
Their slots catalog is decent honestly. They’ve got stuff from Pragmatic Play, Betsoft, and Big Time Gaming — meaning Gates of Olympus, Gonzo’s Quest, all the popular ones. Probably close to 2000 games total if you count everything. Live casino runs on Evolution which is smooth — tried blackjack and Crazy Time with real dealers and zero lag issues.
One thing that annoyed me a little was withdrawal times. Withdrew via Visa and waited almost two days for my first withdrawal. After that though it was faster. They accept credit cards, Skrill, Neteller, and crypto so that covers pretty much everything you’d want. I’d look at the full bonus details on Craybet if you’re interested.
Mobile experience on Craybet on my phone is actually smooth. There’s no app to download though the web app loads fast and everything works fine. Played some slots on the bus and had zero lag or glitches.
Customer service on Craybet has been okay — there’s a chat widget that gets you a person in under five minutes most times. Reached out once about my verification docs and got it fixed same day. Not sure about Curacao licensed and that’s typical of offshore casinos. It’s not flawless — the bonus wagering could be lower — but overall I’m still using it.
So I’ve been playing on Craybet for like six weeks or so and wanted to share my experience because there’s not a ton of talk about them in this forum. I signed up on a whim and signing up literally took 90 seconds. Minimum deposit is $10 and that’s pretty standard. Got a sign-up bonus — matched my first deposit 100% up to 500 and 50 free spins on Gates of Olympus. Rollover is 35x and that isn’t amazing but I’ve dealt with worse.
The game library is bigger than I expected. They’ve got stuff from Pragmatic Play, Evolution, plus Play’n GO — so like Book of Dead, Starburst, that kind of thing. Somewhere around 1500-2000 slots total if you count everything. Live casino is powered by Evolution which is smooth — tried roulette and Lightning Roulette with actual croupiers and it worked great.
One thing I wasn’t thrilled about was how long cashouts take. Withdrew via Visa and it took about 48 hours for my first withdrawal. After that though it dropped to like 24 hours. You can use credit cards, Skrill, Neteller, and crypto so that covers most bases. You can look at the full bonus details over at svnewtech if you’re interested.
Mobile experience on Craybet on mobile worked better than expected. No dedicated app — the mobile site loads fast and all the games load no problem. Played Book of Dead in bed and didn’t notice any performance issues.
Support at Craybet has been okay — they have live chat that actually connects in under five minutes when I’ve used it. I contacted them about a bonus that didn’t credit and it was resolved pretty quickly. Licensing is Curacao-based from what I can tell which is standard for offshore casinos. It’s not flawless — the bonus wagering could be lower — but for what it is I keep coming back.