我是Android通知频道的新手。我遵循了Google Dev docs关于它的教程,但是我在推送通知时遇到了一些麻烦。我的问题是,如果我得到一个通知,并滑动-取消它或只是不点击它,下面的通知与旧的滑动-取消或未触及的通知。通知正在累积增加。
我的代码如下:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "some_channel_id";
CharSequence channelName = "Some Channel";
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, importance);
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
notificationChannel.enableVibration(true);
notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
notificationManager.createNotificationChannel(notificationChannel);
int num = (int) System.currentTimeMillis();
Notification notification = new Notification.Builder(this)
.setContentTitle("Some Message")
.setContentText("You've received new messages!")
.setAutoCancel(true)
.setSmallIcon(R.drawable.fav_ico)
.setChannelId(channelId)
.build();
notificationManager.notify(num, notification);
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
compile "com.android.support:appcompat-v7:26.0.+"
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'id.zelory:compressor:2.1.0'
compile 'net.gotev:uploadservice:3.0'
compile 'dev.dworks.libs:volleyplus:+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
请尝试此代码
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel mChannel = new NotificationChannel(LOCATION_CHANNEL, LOCATION_NAME, importance);
mChannel.enableLights(false);
mChannel.enableVibration(false);
int id = getApplicationInfo().icon;
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, mChannel.getId())
.setSmallIcon(id)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.location_notification_text))
.setPriority(NotificationManager.IMPORTANCE_DEFAULT)
.setVibrate(new long[] {0L})
.setChannelId(mChannel.getId())
.setAutoCancel(true);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (manager != null) {
manager.createNotificationChannel(mChannel);
manager.notify(NOTIFICATION_ID, mBuilder.build());
}
首先,我想声明我一直在研究推送通知和web通知之间的关系,但我有点困惑。 我从这里读到PWAs的推送通知在Safari上的iOS(iPhone)不起作用:从PWA向iOS发送推送通知 然而,如果iPhone用户使用的是Chrome,这是否意味着它们可以工作呢?或者推送通知在任何浏览器上对iPhone中的PWAs都不起作用? 这就把我带到了web通知。web通知在后台对PWAs起作用吗?我的问题是w
我们正在尝试在我们的一个应用程序上实现推送通知。 对于Andriod,我们使用Firebase注册,下载google-services.json文件并将其添加到我们的native/Andriod目录。 在模拟器上一切正常,但在Andriod设备上,推入注册失败,错误代码为0,INVALID_PARAMETERS(由pushRegistrationError回调方法给出)。
问题内容: 我正在使用第一个Android应用程序来使用Google Cloud Messaging(GCM)服务进行推送通知。我已经可以从服务器应用程序成功发送消息,并将消息的内容记录在客户端应用程序的GCMIntentService类中的onMessage事件中。但是,我在设备上看不到任何视觉信息,表明已收到消息。我希望该消息会出现在手机的下拉通知列表中,就像iPhone一样。是否必须手动编码
通过上面的行,我得到了一个URL,它将在大约一个月内有用。 现在我不可能做的是将推送通知发送到应用程序。 任何关于如何使用Uri和如何将信息发送到它的光我会很高兴,因为我的400错误,那是关于我的post消息的一些错误。 我可以在发布或调试模式下获得推送通知吗? 使用PHP可以完成带有正确Uri的推送通知吗?
我有一些关于实现推送通知的问题。事情是, > 订阅对象中的所有数据都是必需的吗?或者只有终点。 如果用户登录的设备超过10台,我是否需要为每个设备存储订阅值?是这样的吗?还是应该存储上次登录设备的订阅值?如果是这样,那么其余9个将不会收到任何通知。 如果您正在存储所有loggedin设备的订阅值,那么用户是否登录了多个浏览器?他会在每个浏览器中收到通知吗?这是标准做法吗? 欢迎提出建议,任何标准做
我有一个React原生应用程序(在iOS上测试),正在尝试合并推送通知。我正在使用以下模块:https://www.npmjs.com/package/react-native-firebase-push-notifications. 我尝试运行示例应用程序代码,并能够获得(1)消息令牌和(2)从我的设备成功获得权限。 我正在尝试从Firebase发送测试通知,并且正在使用我设备的令牌。但是,触发