我想展示一个
notification
具有
custom sound.
我用过
firebase console
到
throw an notification
.
这是我的代码:
Notification notification = builder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(pendingIntent)
.setSound(notificationSound)
.setStyle(inboxStyle)
.setWhen(getTimeInMilliSec(timeStamp))
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon))
.setContentText(message).build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID_SMALL_IMAGE, notification);
Here notificationSound = Uri.parse(SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() + "/raw/notification");
I placed my notification.mp3 file here: res/raw/notification.
我拿到了
通知
正如所料,但我没有得到任何
notification sound.
logs
当我得到
通知
11-14 10:08:31.200 16509-16509/com.hago.ntr D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
11-14 10:08:31.220 16509-16509/com.hago.ntr D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
11-14 10:08:31.272 16509-16509/com.hago.ntr I/FA: App measurement is starting up, version: 9683
11-14 10:08:31.272 16509-16509/com.hago.ntr I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
11-14 10:08:31.272 16509-16509/com.hago.ntr D/FA: Debug-level message logging enabled
11-14 10:08:31.272 16509-16509/com.hago.ntr D/FA: AppMeasurement singleton hash: 266608187
11-14 10:08:31.299 16509-16509/com.hago.ntr V/FA: Collection enabled
11-14 10:08:31.299 16509-16509/com.hago.ntr V/FA: App package, google app id: com.hago.ntr, 1:317122300577:android:6c0b483c0a4e3f40
11-14 10:08:31.299 16509-16509/com.hago.ntr I/FA: To enable faster debug mode event logging run:
adb shell setprop firebase.analytics.debug-mode com.hago.ntr
11-14 10:08:31.343 16509-16509/com.hago.ntr V/FA: Registered activity lifecycle callback
11-14 10:08:31.345 16509-16509/com.hago.ntr I/FirebaseInitProvider: FirebaseApp initialization successful
11-14 10:08:31.347 16509-16509/com.hago.ntr I/InstantRun: starting instant run server: is main process
11-14 10:08:31.354 16509-16552/com.hago.ntr V/FA: Using measurement service
11-14 10:08:31.368 16509-16552/com.hago.ntr V/FA: Connecting to remote service
11-14 10:08:31.459 16509-16552/com.hago.ntr I/FA: Tag Manager is not found and thus will not be used
11-14 10:08:31.465 16509-16552/com.hago.ntr D/FA: Logging event (FE): _nr, Bundle[{_o=fcm, _ndt=0, _nmt=1510634308, _nmid=7758633434821297510}]
11-14 10:08:31.468 16509-16552/com.hago.ntr V/FA: Using measurement service
11-14 10:08:31.468 16509-16552/com.hago.ntr V/FA: Connection attempt already in progress
11-14 10:08:31.473 16509-16552/com.hago.ntr D/FA: Connected to remote service
11-14 10:08:31.473 16509-16552/com.hago.ntr V/FA: Processing queued up service tasks: 2
11-14 10:08:36.494 16509-16552/com.hago.ntr V/FA: Inactivity, disconnecting from the service
可能有什么问题?