FCM Notification in iOS doesn't play sound when received

后端 未结 3 1562
一向
一向 2020-12-10 11:49

I am using Firebase push notifications in my iOS Application. Although I am able to send the notification by sending below payload, it doesn\'t play a sound when received. <

3条回答
  •  猫巷女王i
    2020-12-10 11:54

    When using the FCM admin SDK, you have to specify sounds separately for Android and Apple devices:

    let message = {
        notification: {
            'body': 'This is the message the user sees',
        },
        data: {
            'param1': 'specify some extra data here',
        },
        // Apple specific settings
        apns: {
            headers: {
                'apns-priority': '10',
            },
            payload: {
                aps: {
                    sound: 'default',
                }
            },
        },
        android: {
          priority: 'high',
          notification: {
              sound: 'default',
          }
        },
        token: 'target FCM token goes here',
    };
    

    (Note: I've only tested the Apple settings thus far)

提交回复
热议问题