当前位置:网站首页>[must see for developers] [push kit] collection of typical problems of push service 3
[must see for developers] [push kit] collection of typical problems of push service 3
2022-07-22 14:48:00 【Huawei Developer Forum】
【 Problem description 】
Can't get Push Token, How to solve ?
【 Solution 】
1. Check Push push API Whether the rights and interests are opened .
2. Check AGC Whether the corresponding information of the console application is correct .
3.EMUI 9.0.0 Of Push Token Please return with onNewToken The information returned shall prevail , Ensure that the corresponding service class is configured in the manifest file
4. clear hms core Cache and try again ( Find settings - application - Application management - Search for hms core, Clean up the cache or click the three click buttons in the upper right corner , Uninstall the update to the latest version and try again )
5. Uninstall and reinstall the application before getting it again Push Token
【 Problem description 2】
Lead to Push Token What are the reasons for the change ?
【 Solution 】
Token It will change in the following scenarios, including but not limited to :
1. Uninstall and reload the application .
2. Application call logout Token Method .
3. The user restores the factory settings .
4. Clear application data , Re enter the app .
matters needing attention :token It is changing.
1. Don't use fixed judgment Token length , Because the subsequent length is variable .
2. Applied Token To update regularly ( It is recommended that the application get Token, If it is different from the last one , The newly acquired Token Report to your server ).
3. Do not use Token Track and mark users .
【 Problem description 3】
Through the end-to-side method , Modify the number of desktop corner marks , When the number of subscripts is 0 when , The corner mark does not display
【 Solution 】
private void changeBadge(Application application, int number){
String packageName = application.getPackageName();
Bundle bundle = new Bundle();
bundle.putString("package", packageName);
ComponentName launchClassComponent = application.getPackageManager().getLaunchIntentForPackage(packageName).getComponent();
if (launchClassComponent == null) {
return;
}
String launchClassName = launchClassComponent.getClassName();
bundle.putString("class", launchClassName);
bundle.putInt("badgenumber", number);
try {
Bundle result = application.getContentResolver().call(Uri.parse("content://com.huawei.android.launcher.settings/badge/"), "change_badge", null, bundle);
Log.i(TAG, "clearBadge result = " + result);
} catch (Exception e) {
Log.i(TAG, "clearBadge error ");
}
}
【 Problem description 4】
Through the following code , Manually add message notification channels on the end side
【 Solution 】
@RequiresApi(api = Build.VERSION_CODES.O)
private void addNotificationChannel(){
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Create a notification channel instance
// And set properties for it
// Notification channel ID, Write casually
String id = "my_channel_01";
// The name of the notification channel that users can see ,R.string.app_name Namely strings.xml The parameters of the file , Just customize one
CharSequence name = getString(R.string.app_name);
// Description of the notification visible to the user
String description = getString(R.string.app_name);
// structure NotificationChannel example
NotificationChannel notificationChannel =
new NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH);
// Configure the properties of the notification channel
notificationChannel.setDescription(description);
// Set the flash when the notification appears
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.RED);
// Set the vibration when the notification appears
notificationChannel.enableVibration(true);
notificationChannel.setShowBadge(false);
notificationChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 100});
// stay notificationManager Create notification channels in
manager.createNotificationChannel(notificationChannel);
// Blue words are a new method , Old quilt api To give up
Notification notification = new NotificationCompat.Builder(this, id)
.setContentTitle(" title ")
.setContentText(" Content 666666666666666666666666666")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher_background)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.btn_round_background))
.build();
manager.notify(1, notification);
}
For more technical articles , Welcome to visit https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
- MySql集群之集群配置与验证(四)
- 2022 low voltage electrician examination simulated 100 questions and simulated examination
- 6、学习MySQL 删除数据库
- Single page reference record last sliding position
- DCM10- 安全访问 ($27)的功能和配置【基于DaVinci Configurator Classic】
- MySql集群之多实例数据库搭建(二)
- Checking the wide IP range of SPF records will undermine the security of e-mail
- 【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?
- OS7-资源的死锁
- y73.第四章 Prometheus大厂监控体系及实战 -- blackbox exporter安装和grafana安装(四)
猜你喜欢
Session layer and addressing mode of UDS diagnostic service
IDM下载器软件激活序列号错误如何解决?
Shanghaofang - project summary
【AGC】增长服务2-应用内消息示例
Mysql語句的RegExp的用法與案例
【攻防世界WEB】难度二星6分入门题(上):webshell、command_execution、xff_referer、php_rce、Web_php_include、NewsCenter
Requirement: how to import the MD file containing the public drawing bed pictures into the language bird in the form of graphics and text- 2022.7.17 (resolved)
Internet Download Manager老牌下载器最佳的电脑下载工具
DCM10- 安全访问 ($27)的功能和配置【基于DaVinci Configurator Classic】
Os7 resource deadlock
随机推荐
【idea】idea常用快捷键
winodos下配置laradock
url链接中特殊字符转义方法
Usage and cases of regexp of MySQL statement
Sword finger offer special assault edition day 6
Troubleshooting - find the loop through lldp information (take H3C S5100 as an example)
electron-builder 打包 serialport 成功
[deep learning] Yolo to VOC VOC to Yolo
【Harmony OS】【ARK UI】ETS的List实现下拉刷新功能实现
Mysql语句的RegExp的用法与案例
Collection of relevant materials such as the Blue Bridge Cup, stema technology literacy video
排错-通过LLDP信息查找环路(以H3C S5100为例)
2022 crane driver (bridge crane only) examination question bank and answers
DCM09- ReadDataByIdentifier ($22)的功能和配置【基于DaVinci Configurator Classic】
HCIA-R&S自用笔记(17)OSPF实验与路由综合实验
我的创作纪念日
2022.7.11-7.17 AI行业周刊(第106期):竭尽全力,努力就好
Functions and configuration of dcm09- readdatabyidentifier ($22) [based on DaVinci configurator classic]
378. 有序矩阵中第 K 小的元素 ●●
My creation anniversary