我正在尝试使用firebase-admin
中的Java
为 Ionic混合应用构建推送通知,但它无法正常工作,并且响应如下:
projects/sample-123/messages/5923624590529423486
没有运行时错误。 我为此编写的代码是:
public static void main(String [] args)引发IOException, FirebaseMessagingException {
FileInputStream serviceAccount = new
FileInputStream(“ D:\ Workspaces \ 883lie-5f06e-firebase-adminsdk-o3uaf-79093500a0.json”);
FirebaseOptions options = new FirebaseOptions.Builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) .setDatabaseUrl("https://sample-123.firebaseio.com").build(); FirebaseApp app =FirebaseApp.initializeApp(options); Message message = Message.builder() .setNotification(new Notification( "$GOOG up 1.43% on the day", "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")) .setAndroidConfig(AndroidConfig.builder() .setTtl(3600 * 1000) .setNotification(AndroidNotification.builder() .setIcon("stock_ticker_update") .setColor("#f45342") .build()) .build()) .setApnsConfig(ApnsConfig.builder() .setAps(Aps.builder() .setBadge(42) .build()) .build()) .setTopic("industry-tech") .build(); System.out.println(FirebaseMessaging.getInstance(app).send(message));
}
我是整个android和firebase的新手。而且我不知道我是否缺少任何关键的步骤或类似的事情,所以请在这里帮助我。预先感谢。