我正在编写一个包含聊天系统的应用程序.我正处于一个需要为我的用户聊天的阶段.我有一个服务器端应用程序存储消息很好,但我不知道从Android设备与它通信的最佳方式是什么?
我的应用程序如何知道新数据的最大延迟,例如一秒钟?我是否需要每秒询问服务器,或者是否有任何其他方式通知应用程序已发送新消息,然后调用服务器获取数据.
你有建议如何构建消息吗?我的意思是可能会有很多聊天同时进行.
您认为解决此问题的最佳方法是什么?
谢谢
我决定使用另一个StackOverflow帖子的灵感来建立一个通知系统,该帖子建议我从通知正文中分解通知.因此,我有以下架构:
notifications
id | user_id | notification_object_id | is_read
notification_objects
id | message | type
Run Code Online (Sandbox Code Playgroud)
我已经设置了这种方式,因此我可以创建一个通知对象,并在通知对象适用于多个人的情况下将其发送给多个用户.类型是按类型将消息压缩成一个通知,类似于Facebook所说的方式,"John Doe,John Smith和其他27个用户评论......"而不是给你29个单独的通知.
(表和列的命名方案适用于CakePHP 3的'包含')
我需要帮助的是一种方法来绑定将在请求中扮演角色的不同用户或对象.用户可能已经评论过,因此我可能需要消息的用户的user_id,并且需要将其存储在某处.
除了用户之外还有其他情况; 人们可能想知道评论的ID,以便他可以点击通知并直接发表评论/ 81.我有很多用例,我想将不同类型的id存储为其他表(用户,评论,文章等)的外键,其中一些可能需要两个外键(比如说你想提及" Chris has评论了你的文章 '如何向StackOverflow寻求帮助'",并为Chris提供了user_id,并在通知中链接了文章的文章ID.
每种不同类型的通知都可以具有从中提取信息所需的不同值和表.什么是开始创建此架构的好地方?
我正在使用redis sorted sets来保存用户通知.但由于我从未做过通知系统,我问的是我的逻辑.
我需要为每个通知保存4件事.
我的问题是如何在排序集中存储这种类型的结构?
ZADD users_notifications:1 10 1_A_Y_Y
ZADD users_notifications:1 20 2_A_Y_N
....
Run Code Online (Sandbox Code Playgroud)
在redis中有更好的方法来做这种类型的东西吗?在上面的例子中,我在每个元素中保存了四个东西,我需要在服务器语言中用下划线分割.
我是jquery世界的新手.我不知道如何在wordpress网站中实现"Noty - Notification"插件,如何创建通知和动画等.文档不包含帮助文件
这些是插件的内容
布局[FOLDER](包括bottom.js,bottomleft.js,top.js,topright.js等文件...
打包[FOLDER](包括两个文件jquery.noty.packaged.js和jquery.noty.packaged.min.js)
主题[FOLDER](包括bootstrap.js,defalut.js和relax.js)
jquery.noty.js [FILE]
promise.js [FILE]
我正在为java教程构建一个简单的Android应用程序,其中我想保留一个稍后阅读选项,用户可以使用该选项安排时间进行阅读,并且在指定时间我的应用程序应该向用户发出通知.即使我的应用程序当时没有打开,他也应该在通知栏中收到通知.我是android的新手,不知道怎么做.有人可以帮帮我吗?作为ai是新手的详细解释可能会更有帮助.谢谢提前:-)
我刚刚导入了一个android项目,并且在Notification部分中,我必须使用setLatestEventInfo。但是Android Studio说无法解析方法setLatestEventinfo。这是我的代码段,请在回答时帮助您编辑我的代码
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,"CEPF Mobile",0);
Intent notify_intent = new Intent(context,SpecialSerivceReportActivity.class);
notify_intent.putExtra("filename", "Special Service Report");
notify_intent.putExtra("URL", urls[0]);
PendingIntent contentIntent = PendingIntent.getActivity(context,(int)System.currentTimeMillis(),notify_intent,PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, "CEPF Mobile", "New post in Special Service Report", contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND ;
nm.notify((int)System.currentTimeMillis(),notification);
}
else if(message.equalsIgnoreCase("Special Columnist Blog"))
{
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher,"CEPF Mobile",0);
Intent notify_intent = new Intent(context,SpecialSerivceReportActivity.class);
notify_intent.putExtra("filename", "Special Columnist Blog");
notify_intent.putExtra("URL", urls[1]);
PendingIntent contentIntent = PendingIntent.getActivity(context,(int)System.currentTimeMillis(),notify_intent,PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, "CEPF Mobile", "New …Run Code Online (Sandbox Code Playgroud) 我想在上午10点创建每日通知,每天都有不同的内容.
func createNotification() {
let dateComp:NSDateComponents = NSDateComponents()
dateComp.hour = 10; // supposed to run each day at 10AM
var myCalendar:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
var date:NSDate = myCalendar.dateFromComponents(dateComp)!
let localNotification = UILocalNotification()
localNotification.fireDate = date
localNotification.alertBody = getContentStringForNotification() // Method returns different string for each date
localNotification.repeatInterval = .Day // Repeats every day
localNotification.timeZone = NSTimeZone.defaultTimeZone()
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
Run Code Online (Sandbox Code Playgroud)
它重复通知.他们不断重复并返回昨天的通知.我搜索了Stack社区的问题,我没有找到解雇它们的正确方法.
我认为:
帮助:
我错过了什么?代码欢迎.谢谢!
我有一个通知,我正在通过服务打电话.我想在通知点击时再次呼叫该服务.但是通知点击无法进入方法.
Intent intent = new Intent(this, MyService.class).setAction(ACTION_1);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.food)
.setContentTitle("notification")
.setContentText("near by you!");
NotificationManager mNotificationManager =(NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
Run Code Online (Sandbox Code Playgroud)
我想打电话的方法是
if (ACTION_1.equals(resultPendingIntent)) {
getRecommendation();
}
mBuilder.setContentIntent(resultPendingIntent);
mNotificationManager.notify(id, mBuilder.build());
Run Code Online (Sandbox Code Playgroud)
我试过以下链接但无法解决我的问题. 如何通过单击通知来执行方法
我需要一些指导,所以对于我的应用程序,我正在寻找使用本地通知每天早上7点发送通知.
我遇到的问题是如何使本地通知的内容主要是主体和附加图像?因为它每天都会因用户而异.
什么是最好的方法,因为你无法编辑未来的通知.