Swift Firebase Send Push Notification [duplicate] - swift

This question already has answers here:
Is it possible to send PushNotifications, using Firebase Cloud Messaging (FCM) to special UDID, directly from device?
(6 answers)
Closed 6 years ago.
I was wondering how I could send a push notification by code from my app, via Firebase? I am only able to send a push notification from my Firebase Notification-console as of right now, but I would like to figure out how to send one programmatically. Any ideas on where I can find more info on this? Please point me in the right direction! I tried to check out a project on GitHub by Firebase (quickstart), but I have to say that including that project, it's very little information on this. I was lucky to find a tutorial on YouTube that at least allowed me to teach myself how to use remote notifications.
Thanks in advance!

You can, Firebase (formally Cloud Messaging) provides REST API to send push notifications, checkout the following documentation,
https://firebase.google.com/docs/cloud-messaging/downstream
https://firebase.google.com/docs/cloud-messaging/server
You have to construct the payload, generate Server API Key from Firebase Console and send http request to Firebase endpoint (https://fcm.googleapis.com/fcm/send)
And if you are looking for any library, here is the one which works
http://www.java2s.com/Code/Jar/g/Downloadgcmserverjar.htm
it will send push to GCM server, but it works with Firebase too(we are currently using it)
i don't currently find any official SDK provided by firebase to send push notifications

Related

Flutter Laravel Push Notification without using any third party like(firebase,onesignal..etc)

I'm making a mobile app that has push notification, from frontend I'm using flutter and backend I'm using laravel api and Postgres12 as database. I need to do a push notification where laravel will notify flutter of new notification whenever the database is updated. How to make a a reliable connection between flutter and laravel and that the push notification will work. Please help I have try searching for answers everywhere but I couldn't find the one that can help me solve the problem.
Better I understand, you can not make your own push notification server. What you can do is use the available services like firebase and can't doesn't mean impossible.
read this link
Check out this Awesome Notification Package. This might be helpful for you!

How to send notifications to specific device on Flutter/Firebase Cloud Messaging without using Firebase Cloud Messaging Console [duplicate]

This question already has answers here:
Send notification over device using FCM and Flutter
(1 answer)
How to send push Notification using FCM and Flutter(One to Another Device)?
(1 answer)
Flutter: How can i send push notification programmatically with fcm
(3 answers)
Closed 1 year ago.
I can send notifications to all devices via Firebase Cloud Messaging Console. I can receive them in my Flutter app. That's not a problem.
But I want to send notifications to specific devices. Not to all of them. And I want to send notifications in Flutter. I don't want to use Cloud Messaging Console for that because I have an Blog Application. In this application, when user follows X Person, X person needs to get a notification that "XYZ followed you!". Just like Instagram. How can i achieve that in Flutter/Firebase?
I don't have any server side application. I only have Flutter application and as Backend I use Firebase Firestore.
What's wrong with using cloud functions? Makes your life easier, and you have more abilities as a site admin.
There is a way to send messages over HTTP requests in your fluter app. But this means that you will be storing your messaging key in your code and shipping it, this is not advise, neither best practice.
Regardless of the method you decide to proceed with, you will also have to capturing the devices' FCM tokens somewhere in your FireStore database, because that is the address you want to push your notifications to.
Using cloud functions is advised, it has great documentation, and it's almost for free up to 2 million cloud function invocations per month, then it's around $0.4 for every 1 million function, do you realize what that means if you have 2 million notifications per month?

Is it possible to create Custom Push Notifications with a REST service backed server?

I have an OpenEdge database, I have created a REST Service and am able to CRUD to it from the outside World.
I have created a Nativescript app that can pull data from the REST service etc, but now i want Push notifications.
I know about the Progress Kinvey backend, and Firebase backend with their push notification features but i don't want to use them.
is there a way to create my own Push notifications on my REST server etc?
So first I would like you to understand how Push Notification works just to make sure we are on same page,
Once your app is installed, you can query for a unique token and save it in your backend for future use. Whenever you want to send a push notification, you have communicate with APNs (Apple Push Notification Server) / FCM (Firebase Cloud Messaging) in order to send a push notification to your iOS / Android device using the unique token you acquired earlier.
So now you must use Firebase as that is the only way you can communicate with Android, yet you may choose to communicate with APNs yourself. But in my opinion, it will be a overhead for you as both have their own protocols, you will have to distinguish your tokens between iOS & Android, use appropriate protocols etc.,
I would suggest you to go with just Firebase plugin (until you are super familiar with APNs already), so you don't have to worry which platform the token belongs to, update / revoke invalid tokens over time etc., FCM has pretty decent APIs & Documentation that can make your life easy here.
i strongly recommend you to see my answer here answer here.
from it:
when you want to pull anything from place_1(e.g. api) to place_2(e.g. browser_client) you most have an identifier of the
place_1_resource (which commonly is the uniform-resource-locator of
api)
when you want to push anything from place_1(e.g. notification_central_server) to place_2(cellphone_client) you most
have an identifier of the place_2_resource
if you don't have any identifier for a cellphone which you want to
send it a notification, your server dont know where to send that
notification so we need a resource_identifier_like for cellphones
which is actually a device_token_like and you have just one approach
to get this device_token_like and that is the FCM/APNS

Sending push notifications between devices using Parse and Swift

I have configured my app to receive push notifications through Parse, which I can send from the Parse dashboard, but I would like to send notifications between devices, specifically when a button is clicked from either device. I cannot find documentation about this...wondering if anyone has experience doing this.
You have to store the current user into Installation class then send push notification using PFInstallation Query and PFPush.
Please refer this parse documentation for more details to send notification.
https://parse.com/docs/ios/guide#push-notifications
or refer this site Swift Parse : How to Push Notification To a Specific Device/objectId

Retrieve and save all Apple Push Notification Device Tokens in our server for APNS?

Am trying to integrate Apple Push Notification in my app. I have studied the Apple Document and other tutorials for my understanding. But, still i have a doubt to create a server and store all Apple Push Notification devicetokens in the database. Am not going to work on Server side but, i need to explain the approach to my client. I need to understand to create a APNS server provider and save all the apple push notification device tokens and retrieve all devicetoken and retrieve a single devicetoken to send notificaions. Can you please suggest me any sample code to save all apn devicetokens and retrieve from the server? I suggest my client to create a server in C#.net platform is this correct? Thanks in advance.
Essentially, you just need to decide on a way for your app to let your servers know the device tokens. So, there are many ways to achieve this.
If your server side already involves a website, the easiest way would be to use HTTPS to do a POST request from your app. Then, the server-side code can be written as if it is handling form request from browsers. I can't really give you sample code since I don't know any C#, but this should be familiar to any web developer.