The absence of the receiverISOCountryCode
field in the payload sent to the text server through the deferQueryRequestToNetwork
method appears to be by design, reflecting a deliberate choice by Apple to limit the data being transmitted for reasons such as privacy or simplicity. Here's an explanation:
-
Privacy Considerations
Apple tends to minimize the amount of potentially sensitive user data transmitted to external servers. Including the ISO country code could inadvertently expose information about the recipient's location, which may not be necessary for the text server's logic.
-
Data Minimization Principle
By omitting the ISO country code, Apple adheres to the principle of transmitting only essential information to reduce risks and comply with privacy regulations like GDPR. The deferQueryRequestToNetwork
payload likely prioritizes fields that are strictly necessary for spam filtering or other server-side logic.
-
Server-Side Independence
The deferQueryRequestToNetwork
payload is designed to allow the server to independently interpret the context of the query. The server may already have alternative ways of determining the ISO country code if needed, such as through metadata, IP-based geolocation, or pre-established associations with the user's profile.
-
Extension Context Responsibility
The receiverISOCountryCode
field is part of the ILMessageFilterQueryRequest
object provided to the app extension. The extension has access to this data and is expected to handle country-specific filtering logic locally. If the extension defers to the server, it does so with a reduced data set, likely because it assumes the server doesn't require the country code or has alternative means to determine context.
If your server requires the receiverISOCountryCode
to perform its filtering logic:
- Modify the extension logic to include the ISO country code in the deferred request's payload before transmitting it.
- For example, you can enrich the payload within the
deferQueryRequestToNetwork
method by appending the receiverISOCountryCode
explicitly to the query
or app
fields.
let isoCountryCode = request.receiverISOCountryCode
let enrichedPayload: [String: Any] = [
"_version": 1,
"query": [
"sender": request.sender,
"message": [
"text": request.messageBody
],
"receiverISOCountryCode": isoCountryCode
],
"app": [
"version": "1.1"
]
]
// Send this payload to the server.
This approach allows you to balance between Apple's default payload structure and the specific requirements of your text server.