我不知道任何推送通知。我在尝试学习。但我无法理解。 我有服务器的一个表mysql数据库system.if任何更改都在表中进行意味着我要显示为通知到Android手机 请给我的建议,我如何从服务器推送通知到Android手机
回答
这里是这个一个很好的解释:
http://quickblox.com/developers/SimpleSample-messages_users-android
总的步骤是:
- 创建一个谷歌的API项目
- 启用项目推送通知,并获得APIķ EY
- 获取通过Android应用的注册ID(每个装置具有用于特定应用的注册ID)
- 创建一个服务器应用程序通过谷歌服务器通过GSM
- 创建通知何时发送你的推送消息作为推送通知你在应用程序端得到推送通知
这不是我可以在这里写的所有细节。每一步都使用Google。
您可以检查出火力地堡......看看这个链接
https://firebase.google.com/docs/cloud-messaging/
https://firebase.google.com/docs/notifications/
这个链接是足够的了解推送通知
至于发送通知时数据在数据库更改中,使您的API向FCM服务器发送请求,以便向客户端传递必要的数据。
第一件事 - Google推送通知称为GCM(Google Cloud Messaging)。错误的名称使用可能会导致您输入错误的信息或教程。另一方面,你应该依赖开发人员。在这种情况下,您可以从Google Developers网站开始,在那里您可以找到大部分基本信息和代码示例。 https://developers.google.com/cloud-messaging/。
其实现在大部分最近使用的,ü项目中推送通知FCM ....用于构建 最好的链接推送商品通知:link
步骤进行推送通知 - 火力地堡云端通讯教程为Android
- 转到Firebase控制台并创建一个新项目。
- 现在把你的应用程序名称,并选择你的国家。
- 现在点击向您的Android应用添加Firebase。
- 现在您必须输入您的项目包名称并点击添加应用程序。
- 点击添加应用后,您将获得google-services.json文件。
在应用程序方面
- 现在回到你的Android项目。转到应用程序文件夹并粘贴google-services.json文件
现在转到您的根级build.gradle文件并添加以下代码。
a。添加此行 classpath'com.google.gms:google-services:3.0.0'
b。添加此行 compile'com.google.firebase:firebase-messaging:9.0.0'
现在同步您的项目。
创建一个名为MyFirebaseInstanceIDService.java类,并用下面的代码:
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { private static final String TAG = "MyFirebaseIIDService"; @Override public void onTokenRefresh() { //Getting registration token String refreshedToken = FirebaseInstanceId.getInstance().getToken(); //Displaying token on logcat Log.d(TAG, "Refreshed token: " + refreshedToken); } private void sendRegistrationToServer(String token) { //You can implement this method to store the token on your server //Not required for current project } }
现在创建MyFirebaseMessagingService.java和写下面的代码:
import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; /** * */ public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "MyFirebaseMsgService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { //Displaying data in log //It is optional Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); //Calling method to generate notification sendNotification(remoteMessage.getNotification().getBody()); } //This method is only generating push notification //It is same as we did in earlier posts private void sendNotification(String messageBody) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("Firebase Push Notification") .setContentText(messageBody) .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); } }
现在我们要定义上述服务在我们的AndroidManifest.xml文件中。因此请按照以下方式进行修改和修改。
<!-- Adding Internet Permission --> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- Defining Services --> <service android:name=".MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> <service android:name=".MyFirebaseInstanceIDService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> </application>
终于
转到火力平台,然后选择您所创建的应用程序。 从左侧菜单中选择通知。 点击新消息。 输入消息,选择单个设备并粘贴您复制的令牌,然后单击发送。与我在视频上一样,并检查您的设备
- 1. Android从服务器通知android手机
- 2. 从服务器发送推送通知
- 3. 从PHP服务器发送推送通知到Android设备
- 4. 从Java RESTful服务器向Android手机发送数据通知
- 5. 无法将推送通知从parse.com发送到android手机
- 6. 发送自动推送通知从MySQL到Android手机
- 7. SignalR在Android手机中推送通知
- 8. Android中是否有推送通知服务,例如Apple推送通知服务?
- 9. 从服务器推送通知
- 10. 从ASP.Net服务器推送通知
- 11. 通过网络服务发送通知到Android手机
- 12. 如何解决特定的Android手机发送推送通知
- 13. IBM Worklight - 如何从SharePoint服务器发送推送通知
- 14. 有些怀疑Meteor服务器发送推送通知到Android
- 15. 服务器如何知道iPhone是否收到推送通知?
- 16. 没有从推到服务器端的推送通知
- 17. 什么工具发送推送通知到Android手机?
- 18. 从我的网站发送推送通知到pushwoosh服务器
- 19. 推送通知从Android手机向Android平板
- 20. Android如何使用drupal服务器接收推送通知
- 21. android推送通知服务比较
- 22. 如何从服务器获得推送通知?
- 23. 服务器为GCM推送通知到android在C#
- 24. 从服务器发送推送通知到的Android设备在Java中
- 25. BB推送通知服务
- 26. 推送通知服务
- 27. 从ASP.NET推送通知到android web服务
- 28. 如何发送推送通知从服务器到iOS应用程序
- 29. iOS手机的差距 - 推送通知不显示通知服务警告框
- 30. 为推送通知购买服务器
http://stackoverflow.com/questions/1378671/push-notifications-in-android-platform – user370305
我登录在c2dm应用程序我填充singup然后我得到消息来自谷歌。之后,我可以做些什么。我不知道请告诉我解决方案。我面临的问题过去7天..请帮我 – naveen
看看我给上述评论的链接.. – user370305