0

Is there any java APNs library out there that has Firebase Cloud Messaging support, I have found Pushy but it looks like it does not support FCM.

I am challenged with being able to send iOS, Android, Web push notifications through Firbase Cloud Messaging from my own app server, and not from the Firebase Console. So far I have some code that as far as I can tell works with FCM for Android devices, I have tested it and I can receive notifications on my Android devices. (I have also tested Pushy for iOS and it works fine, but I need to be able to send the notification to my iOS devices through https://fcm.googleapis.com/fcm/send)

try{
        Sender sender = new FCMSender(serverKey);
        Notification notification = new Notification.Builder("").title("New Message").body("").build();
        Message message = new Message.Builder().notification(notification).addData("data", "Hello World!").build();
        Result result = sender.send(message, "deviceToken", 1);
        System.out.println("Result: " + result.toString());
    } catch(Exception e){
        e.printStackTrace();
    }

and FCMSender is a custom class that extends GCM Sender class but points to the endpoint https://fcm.googleapis.com/fcm/send

public class FCMSender extends Sender {
public FCMSender(String key){
    super(key);
}

@Override
protected HttpURLConnection getConnection(String url) throws IOException{
    String fcmUrl = "https://fcm.googleapis.com/fcm/send";
    return (HttpURLConnection) new URL(fcmUrl).openConnection();
}
}

Can I do the same trick somehow in the Pushy library for iOS devices to send to the endpoint https://fcm.googleapis.com/fcm/send if yes then how? And if not, is there a java APNs library, as mentioned in the beginning, that supports FCM.

Yantes
  • 251
  • 3
  • 18
  • FCM claims to utilize APNs for iOS devices. The details are in the FCM documentation. Can you use that? – Uli Jan 20 '17 at 17:54
  • @Uli yeah I can use that a bit, so you are refering to the following [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref) ? But so far I have been faced with the problem of not being able to find a maven repository or .jar for the messaging sdk, I can only find one for the Firebase core and admin parts. – Yantes Jan 23 '17 at 08:34
  • There's [this](https://firebase.google.com/docs/cloud-messaging/) with more links to iOS. There is a lot more information out there (also under the GCM keyword), you should Google it more. Also a ton of YouTube videos from Google on GCM (and some on FCM). There's [this](https://github.com/google/gcm) and this hard-to-find, mislabeled [server-side reference implementation](https://github.com/google/gcm/tree/master/client-libraries/java/rest-client) – Uli Jan 23 '17 at 16:22
  • I may have found the solution in this [link](https://developers.google.com/cloud-messaging/ios/client). So I need to implement some GCM handling in the iOS app, and then I have to do an import of the already existing APNs tokens to be mapped to valid registration tokens. Which i then can use to send GCMs. I was convinced that it should be achievable without having to make changes to the iOS app, but that is not possible. But thanks for the hints @Uli – Yantes Jan 25 '17 at 10:26

0 Answers0