I whish to create a simple Java project which uses FCM.
I found a lot of tutorials on the web, but unfortunately it is not really clear how it works.
I want to write a simple Java code which sends a push notification message to my phone device (android).
I read through the offical FCM website, but I cannot understand how can I make a real connection between my phone and my Java project?
It needs any device ID or token?
How it works?
Thanks a lot!
To send FCM messages from Java you can use the Firebase Admin SDK. See the documentation on sending messages for full details.
Note: this will only work from a JVM. It is not possible to use the Admin SDK in an Android project.
A little late my answer, a short code to send a notification from android, using: FCM-AndroidToOtherDevice
FirebasePush firebasePush = new FirebasePush("LEGACY_SERVER_KEY");
firebasePush.setNotification(new Notification("title","body"));
firebasePush.sendToTopic("news");
Related
I am currently developing Java web services that run on WebLogic on a server. There is a requirement that I need to send push notifications to mobile devices running on iOS. I do know what is required for developing GCM/FCM for sending notifications to Andriod devices. For iOS, I know there is APNS, but what Java library can I use to send the notifications?
Also, what are the required things (registration ID, etc) needed in order to send via APNS?
Any example codes?
I have googled and found out about java-apns and javapns, but I am not even sure if they are obsolete already.
Thanks in advance.
I can help you with what all are the things which are must to implement APNS. Please note that with the introduction of new HTTP/2.0 APNS API, a lot of things have changed which used to be before. (Good news is : Things have really become easy & simple now)
Would advise you to go through the below link:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html
APNS Prerequisites:
1) APNS SSL Certificate, Key (Same for sandbox & production now, previously used to be different for production/development/voip etc. This is the most important step, as most of the issues related to APNS are due to the wrong certificate generation)
2) device token (specific to per iOS app running on an iOS device, your iOS client app needs to register with APNS to get this device token. Also device token is normally different for development & production environments. So please make sure your using the right token)
Once you have above mentioned certificate,key & device token for your iOS App, you can send APNS notifications from your application provider using APNS interface.
Please note that, device token can change anytime (normally during iOS software upgrade), so its always advisable to obtain fresh device token every time your app is launched.
On your query related to java library for apns, please note new APNS interface has a dependency on HTTP/2.0 . Both open source as well as enterprise versions (like AWS, Urban airship etc) are available which you can select based on your needs. Not sure if AWS supports new HTTP/2.0 interface. However its always advisable to use the latest APNS interface as per Apple guidelines.
Optionally, you can also use GCM as well to implement APNS.
https://developers.google.com/cloud-messaging/ios/start
However, your iOS app may need to register to GCM as well for the same. Basically the iOS device token will be mapped to GCM device token. However, you would still need to generate certificate,key as well as device token as I have mentioned.
I hope it answers your query.
_Ayush
I am trying to get my app id from Telegram API by using the method register.saveDeveloperInfo, but I cannot find the way to do it.
I'm using de MTProto Java library.
This is what I had done by now:
I made my own register.saveDeveloperInfo implemmentation in Java.
I call the method with the corrects params (https://core.telegram.org/api/obtaining_api_id)
The method returns a true boolean but I have not received the sms with my app_id.
When I enter in my app section of the telegram web (https://core.telegram.org/myapp) shows the "Your app is not ready yet" message.
Anyway, I'm trying to use the app_id from the source code of the official client but I can't send or receive message.
Does anyone know how to do it or where can I find more information?
You can get your app api_id and app api_hash from your Telegram app page. This is what you'll be using as of this writing. If you are asked a password, provide the mobile phone number you'll be using to develop and Telegram will send you the password.
If you are asked a password and Telegram didn't send it to you, try to provide the mobile phone number without "+".
Try disabling any anti-spam software or VPN. Disabling ABP for https://my.telegram.org/apps helped me
I have been trying to learn android programming following Ravi Tamada's tutorials - AndroidHive for weeks now.
I created an app that performs Create, Read, Update and Delete actions (CRUD). Similar to this .
Now, what I want in my app is to have another feature that whenever there is a new data created and/or updated in the database, the app sends notification to other android phones that have the same app.
I've researched and come across Google Cloud Messaging, which AndroidHive also have a tutorial for. The way I see it is that it is only the server that can send notification to devices and GCM cannot do: "Device to another Device" For instance, "Device creates data -> send to database -> GCM sends notifs to other devices". Correct me if I'm wrong.
So I've searched again and found that you can use Smack for Instant Messaging app. Similar to something that I want my app to accomplish. But I'm having trouble understanding and implementing Smack to Java and Android.
So what I want to know is:
1.) Is it possible for GCM to listen to a device to check if the app has change the database and sends a notification to other devices that there is a change in the database?
2.) Do you have any "noob-friendly" article links on how to have a basic understanding and implementation of Smack in Java-Android?
Thank you.
Check out the official tutorial on the Android developers site:
http://developer.android.com/google/gcm/notifications.html#upstream
You can just upstream a message to the Google cloud and it will be sent to other devices in the same notification group.
I'd suggest that you always start with the official tutorials first and then move on to third-party blogs, it's just easier that way.
I have posted this question.
I thought that downloading the newest version of gcm will work, but I was wrong. I have downloaded latest version of gcm but still I can't receive notification. I have a GOOGLE API KEY and a sender ID.
Everything is fine when I register the ID - it works fine and it shows in database, but when I try to send a message from the server to my android device, I am not getting the message from the server.
Can any one help me? I have tried some examples as well, but they aren't working. Does anyone have working example, or is my API key is not valid?
Please check your server code whether it access the registration ID of registered android device.
The following link has exact explanation of GCM with simple client side code and server side code.
http://avilyne.com/?p=267
Is there an alternative to using Google C2DM for push notifications with Android? I ask because the app I'm working on will only run when the device is connected to a specific network. It's an app for members of this specific company and notifications will only come from that companies server. Since everything is "in-house" does it even make sense to push them to google just to have them come back to the same network? I've heard something about JMS. Does anyone know if that will work?
There are definitely some options. I played with UrbanAirship a bit and it seems nice. Check it out http://urbanairship.com/
You can try Tokudu . It uses IBM’s MQTT broker to handle the server work. Try it out.