Why is this push notification payload not valid for ACS iOS library

Guy Swartwood 65 Reputation points
2024-02-29T20:47:48.2366667+00:00

Based on this link: https://github.com/Azure-Samples/azure-communication-services-calling-event-grid/blob/main/add-calling-push-notifications-event-grid/ACSCallingNativeRegistrarLite/Models/PushNotificationInfo.cs

I am sending a payload that is a dictionary of :

  • callId = "cc381f9e-e806-4800-afc2-9bb70ab57df2";
  • callerId = "8:acs:98d1ba98-7169-41de-ab12-e7549445a124_0000001d-d1c2-8014-0e04-343a0d000f29";
  • cp = "<long Base64 string>";
  • displayName = "Somebody";
  • eventId = 107;
  • recipientId = "8:acs:98d1ba98-7169-41de-ab12-e7549445a124_0000001d-9efd-f89d-ceb1-a43a0d002e2d"

This payload works when we call PushNotificationInfo.fromMap in Android library, but does not work in the iOS library. We get this error:

Received empty/invalid notification payload. (83) from ACSPushNotificationInfo fromDictionary method.

What are we missing in the payload that iOS requires but Android does not?

To be clear, we are passing in a dictionary with these keys:

  • cp
  • callId
  • callerId
  • displayName
  • eventId
  • recipientId
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
680 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
316 questions
{count} vote

Accepted answer
  1. Sanath Rao 80 Reputation points Microsoft Employee
    2024-03-05T23:29:58.3033333+00:00

    Please pull the latest code here.

    https://github.com/raosanat/communication-services-calling-event-grid.git

     

    The latest commit should fix the bug in extracting CC from IncomingCallContext

    Fix parsing of IncomingCallContext · raosanat/communication-services-calling-event-grid@dfa0479 (github.com)

     

    I tested on iOS and it works consistently now.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Pinaki Ghatak 2,395 Reputation points Microsoft Employee
    2024-03-06T10:15:37.9233333+00:00

    Let’s explore the potential reasons why it works in the Android library but not in the iOS library. as you mentioned above.

    1. Format Differences:
      1. iOS and Android handle push notification payloads differently. Ensure that the payload format adheres to the requirements of each platform.
      2. Specifically, check if the dictionary keys are correctly formatted and match the expected structure for iOS.
    2. Content-Available Flag:
      1. In iOS, the content-available flag is essential for background notifications. Make sure this flag is set correctly in your payload.
      2. For FCM (Firebase Cloud Messaging), use the key content_available with a boolean value (true or false).
      3. For APNS (Apple Push Notification Service), set the content-available field to 1.
    3. Mutable Content:
      1. If your notification payload includes media attachments (such as images), iOS requires the mutable-content flag to be set to 1.
      2. Ensure that this flag is correctly included in your payload.
    4. APNs Headers:
      1. When sending push notifications to iOS devices, ensure that the APNs headers are correctly set.
      2. The apns-push-type header should be set to background.
      3. The apns-priority field should be set to 5.
    5. Simulator Testing:
      1. If you’re testing in the simulator, ensure that you’re using an APNS file with the correct payload.
      2. The APNS file should contain the “Simulator Target Bundle” key if you’re testing on a simulator.
    6. Debugging Tools:
      1. Use debugging tools to inspect the actual payload received by the iOS library. I believe you are doing this already.
      2. Check if any additional fields are required or if there are unexpected values.

    Remember that iOS and Android have different requirements and behaviors for push notifications. Double-check the payload format, flags, and headers to ensure compatibility with iOS. If you’ve addressed these points and still encounter issues, consider examining the iOS library’s documentation, including getting the update, as my colleague mentioned earlier.


    If this information provided here helps solve your issue, please tag this as answered, so it helps further community readers, who may have similar questions.


  2. Guy Swartwood 65 Reputation points
    2024-03-07T23:30:46.9533333+00:00

    The issue turned out to be the eventId being passed. We were passing it as a string in the push notification payload since Android's ACS library requires it. ACS iOS library requires eventId be a number data type instead of a string. Thank you Sanath for helping diagnose this issue.