FCM Notification in iOS doesn't play sound when received

后端 未结 3 1544
一向
一向 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条回答
  • 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)

    0 讨论(0)
  • 2020-12-10 12:06

    your JSON "sound" : "default" should be inside the "notification" key not in the root of the JSON. This JSON should work.

    {
        "to": "myToken",
        "notification": {
             "body": "test",
             "title": "test",
             "sound": "default"
        },
        "priority": "high"
    }
    
    0 讨论(0)
  • 2020-12-10 12:09
        payload = {
            notification:{
                title: 'SOLO has been changed by an administrator',
                body: 'Administrator changed your SOLO schedule',
            },
            android: {
            },
            apns: {
                headers:{
                    "apns-collapse-id": "solo_changed_administrator",
                    "content-available": "1",
                    "apns-priority": "10",
                },
                payload:{
                    aps:{
                        sound: 'default',
                        badge: 12213123223
                    }
                }
            },
            data:{
                type: 'type'
            }
        }
    

    https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#ApnsConfig

    0 讨论(0)
提交回复
热议问题