作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我通过PHP向android发送通知,在android上正常。
但是当我发送多个时,它只显示最后一个,我希望它显示所有。
这可能吗?
我该怎么做?
PHP
$msg = array
(
'nome' => $comando,
);
$fields = array
(
'to' => $token,
'data' => $msg
);
$headers = array
(
'Content-Type: application/json',
'Authorization: key= KEY'
);
#Send Reponse To FireBase Server
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
#Echo Result Of FireBase Server
echo $result;
安卓
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new
NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setSound(alert)
.setContentTitle("teste")
.setContentText("teste "+msg+"!")
.setAutoCancel(true)
.setOnlyAlertOnce(true)
.setPriority(2)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1410, notificationBuilder.build());
最佳答案
很简单:
notificationManager.notify(1410, notificationBuilder.build());
你已经写了 '1410',而不是每次都分配 Unique_Integer_number。
To get unique no everytime:
Random random = new Random();
int m = random.nextInt(9999 - 1000) + 1000;
关于php - 安卓通知火力基地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47667749/
我正在使用 Firebase 在我的应用程序中添加登录/注册。它运行良好,但现在我想检查用户在打开应用程序时是否已经注册并登录,如果是这样,则向他显示主页,否则向他显示登录页面。所以我做了一些搜索,主
我使用 flutter 。我想仅在 2020 年 4 月 26 日这一周将 Firebase 中的 CH 值更新为 false。什么时候有办法? 失败的 Ex.cord: _firestore.col
我来寻求您对我的申请中遇到的问题的帮助。 问题是这样的:新闻源上的帖子位于此捕获中的此帖子 -> [postid] 位置下的数据库中 ,当用户保存帖子时,它在数据库中的存储方式如下:用户 -> [us
我是一名优秀的程序员,十分优秀!