当前位置: 首页 > Web前端 > HTML

开源:ReactNative设置应用角标库

时间:2023-03-28 19:23:28 HTML

鍚庡彴椤圭洰寮€鍙戦渶瑕丷N椤圭洰璁剧疆搴旂敤瑙掓爣銆傛煡鎵剧浉鍏宠祫鏂欏悗鍙戠幇鐩墠杩樻病鏈夌涓夋柟搴撶洿鎺ユ敮鎸侊紝浜庢槸鎯冲埌浜嗘ˉ鎺ヤ袱绔殑鏂瑰紡鍘熺敓瀹炵幇銆傞噸澶嶉€犺疆瀛愮殑鎬濊矾锛屽紑婧愬簱銆侫ndroid杩囩▼涓亣鍒扮殑闂涓€銆佸墠杈堜滑宸茬粡鍋氫簡鍘熺敓瀵瑰簲鐨勫簱锛屼絾鏄皬绫炽€佽崳鑰€绛夋満鍨嬮渶瑕佸崟鐙€傞厤銆傞噰鐢ㄧ殑鏂规鏄坊鍔犲師鐢熶緷璧栧簱锛屽垎鍒€傞厤灏忕背鍜岃崳鑰€鏈哄瀷銆備笌宸ヤ綔銆傚叾娆★紝Android13锛圓PIlevel33锛夊強浠ヤ笂鐗堟湰閫氱煡鏉冮檺鏀逛负杩愯鏃惰幏鍙栵紝搴旂敤閫氱煡榛樿鍏抽棴銆傞渶瑕佸崟鐙坊鍔犳潈闄愶紝鍦ㄥ簲鐢ㄥ惎鍔ㄩ〉鎻愮ず鐢ㄦ埛銆傝В鍐虫柟娉曪紝鍦ㄩ」鐩殑MainActivity.java鏂囦欢涓坊鍔犲涓嬩唬鐮侊紝鍦╫nCreate鍑芥暟涓皟鐢紝閫氱煡notification=null锛沬f(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){NotificationChannelchannel=newNotificationChannel("com.chengfenghuoyun.crm","notification_channel",NotificationManager.IMPORTANCE_HIGH);mNotificationManager.createNotificationChannel(棰戦亾);閫氱煡锛坣ewer.Builder锛夛紱getApplicationContext(),"com.chengfenghuoyun.crm").setContentTitle("").setContentText("").setSmallIcon(R.mipmap.ic_launcher).build();}else{notification=newNotification.Builder(getApplicationContext()).setContentTitle("").setContentText("").setSmallIcon(R.mipmap.ic_launcher).build();}mNotificationManager.notify(1,notification);}ios闂ios绔病鏈塵odel閫傞厤闂锛屼絾鏄渶瑕佸紑鍚痭otification鏉冮檺銆侫ppDelegate.m鏂囦欢涓渶瑕佹坊鍔犲涓嬩唬鐮侊紝1.瀵煎叆UNUserNotificationCenter#import2銆傚弬鑰傽interfaceAppDelegate()3.鐢宠閫氱煡鏉冮檺UNUserNotificationCenter*center=[UNUserNotificationCentercurrentNotificationCenter];center.delegate=self;[centerrequestAuthorizationWithOptions:(UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionBadge)completionHandler:^(BOOLgranted,NSError*_Nullableerror){}];wayne-badgeioscdios&&podinstalluse//importpackageimportRNWayneBadgefrom'react-native-wayne-badge';//浣跨敤鍖匯NWayneBadge.setBadge(1);椤圭洰搴撳湴鍧€https://github.com/wayne214/react-na娆㈣繋鏉ュ埌tive-wayne-badge馃憦馃徎澶уstar猸愶笍鍙傝€冭祫鏂欙細1.https://www.jianshu.com/p/256...2.https://blog.csdn.net/gongsun...3.https://github.com/leolin3101...4.https://developer.android.com...