String dicts and notification localization

Hi,

I've been using string files to localize incoming remote notifications like this:

"training_new_title" = "New training added";
"training_new_body" = "A new training on %@ has been added";

Following the migration to the new string dicts it looks like this:

"training_new_body" : {
      "extractionState" : "manual",
      "localizations" : {
        "en" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "A new training on %@ has been added"
          }
        },
        "nl" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "Een nieuwe training op %@ is toegevoegd"
          }
        }
      }
    },
    "training_new_title" : {
      "extractionState" : "manual",
      "localizations" : {
        "en" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "New training added"
          }
        },
        "nl" : {
          "stringUnit" : {
            "state" : "translated",
            "value" : "Nieuwe training toegevoegd"
          }
        }
      }
    },

Unfortunately as said before notifications are no longer localized and come in as their normal state: "training_new_title" & "training_new_body" .

I am using Firebase messaging service, they send a APNS, that looks like this:

notification: {
  titleLocKey: "training_new_title",
  bodyLocKey: "training_new_body",
  bodyLocArgs: bodyPayload,
}

Do string dicts require any extra steps apart from the standard that I have implemented?

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        completionHandler(.newData)
    }

Thanks in advance for any insights

Hi,

Using the new String Catalog shouldn’t produce a change, because the catalog is compiled as a .string file like before.
I’ve tested using local notifications with String Catalog and it seems to be working.

Can you verify if your String Catalog is included in the target were your string files used to be?
Also the name of the String Catalog file should be the name of the table, which defaults to Localizable (so Localizable.xcstrings).
Otherwise, any chance Firebase is using a custom implementation?

Hi,

Thank you for your reply and confirming that the new catalogs work the same way.

I've checked the logs and how everything is received and I get the following incoming request:

AnyHashable("google.c.sender.id"): 413730047848, AnyHashable("google.c.a.e"): 1, AnyHashable("google.c.fid"): c0dFB2k7vUnMszvlFTjU-J, AnyHashable("aps"): {
    alert =     {
        "loc-args" =         (
            "July 7 16:00"
        );
        "loc-key" = "training_description_changed_body";
        "title-loc-args" =         (
        );
        "title-loc-key" = "training_description_changed_title";
    };
}, AnyHashable("gcm.message_id"): 1688651931999324

Using the following method to send:

const singleMessage: admin.messaging.Message = {
        android: {
          ttl: 3600000,
          notification: {
            titleLocKey: titleLocKey,
            titleLocArgs: titleLocArgs,
            bodyLocKey: bodyLocKey,
            bodyLocArgs: bodyLocArgs,
          },
        },
        apns: {
          payload: {
            aps: {
              alert: {
                titleLocKey: titleLocKey,
                titleLocArgs: titleLocArgs,
                locKey: bodyLocKey,
                locArgs: bodyLocArgs,
              },
            },
          },
        },
        token: token,
      };

If you think that this isn't related to the new string catalogs, then I will search somewhere else.

Thank you in advance.

String dicts and notification localization
 
 
Q