【问题标题】:How to set notifications?如何设置通知?
【发布时间】:2017-12-10 08:16:47
【问题描述】:

请帮助我。我为我的网站创建了一个 Android 应用程序。

现在我想在我更新/上传新内容到我的网站时通知用户。

我的意思是说,当我更新网页内容时,使用我的应用程序的用户必须收到以下通知: * "...被添加到..."
* "现在签出..."

我希望你明白我想说什么。
对不起我的英语不好

即:就像在网页上添加新新闻的报纸应用程序一样。
用户收到“发生某事”的通知

【问题讨论】:

  • 搜索android rss feed
  • 通知是个大课题。您需要搜索它并查看它是如何为 Android 应用程序实现的。然后,如果您有具体问题,可以在这里寻求帮助。

标签: android webview feed


【解决方案1】:

将 Firebase 添加到您的应用程序的最简单的解决方案。

那么你需要Firebase Cloud Messaging Service

compile 'com.google.firebase:firebase-messaging:11.6.2'

将此服务添加到您的清单中

<service
        android:name=".model.notifications.NotificationService">
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
      </intent-filter>
</service>

并创建您的服务

public class NotificationService extends FirebaseMessagingService {

  @Override public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    Timber.d("Message received [" + remoteMessage + "]");

    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent =
        PendingIntent.getActivity(this, 1410, intent, PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this).setSmallIcon(R.drawable.logo)
            .setContentTitle("Notification!")
            .setContentText(remoteMessage.getNotification().getBody())
            .setAutoCancel(true)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    if (notificationManager != null) {
      notificationManager.notify(1410, notificationBuilder.build());
    }
  }
}

如果您转到 Firebase 信息中心的通知面板,您可以向特定用户或使用您的应用的每个用户发送即时通知。

【讨论】:

  • 我知道,但每次我都必须发送通知但我想知道有什么办法......所以通知会自动发送......
  • 为此,每次我登录到我的 firebase 帐户然后向最终用户发送通知...
【解决方案2】:

您可以使用诸如 Firebase 之类的东西来制作推送通知。 这是您可以从here开始的链接

【讨论】:

    猜你喜欢
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    相关资源
    最近更新 更多