<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Łukasz Szyszkowski on Medium]]></title>
        <description><![CDATA[Stories by Łukasz Szyszkowski on Medium]]></description>
        <link>https://medium.com/@lukaszszyszkowski?source=rss-4931caf423d2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*J1ZaW19VM5mg9O4a3WWmQA.jpeg</url>
            <title>Stories by Łukasz Szyszkowski on Medium</title>
            <link>https://medium.com/@lukaszszyszkowski?source=rss-4931caf423d2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:16:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lukaszszyszkowski/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Send iOS Notifications in Different Languages? Guide to Dynamic Localization]]></title>
            <link>https://medium.com/swlh/how-to-send-ios-notifications-in-different-languages-guide-to-dynamic-localization-72bd4035dbbf?source=rss-4931caf423d2------2</link>
            <guid isPermaLink="false">https://medium.com/p/72bd4035dbbf</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[push-notification]]></category>
            <dc:creator><![CDATA[Łukasz Szyszkowski]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 13:45:26 GMT</pubDate>
            <atom:updated>2021-02-24T08:57:03.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNws--5oCuqvnmtVBvgxBg.png" /></figure><p>The best way to set a connection between a user, provider, and an app? System notifications. They allow users to get the latest news in no time. This solution is easy to implement in apps dedicated to one market. But it gets complicated when the messages must be displayed in many languages. In such cases, the dynamic localization of remote notifications can be a real game-changer.</p><p><em>Note that the solution I describe in this article works best for the apps without a server API that can store information about the language of a system or an app.</em></p><h3>Where can you place the content of notifications?</h3><p>There are two most popular ways used for storing the content of the messages. First of all<strong>, you can place it in <em>.strings</em> files</strong>. This solution is nice and easy, providing the translations are defined in advance and compiled with an app.</p><p>This is not an option, though, when the notifications are more descriptive. For example, when you want to include news that applies to a particular location. Fortunately, there’s an alternative way you can use in this case.</p><blockquote>When the app works in multiple language versions, notifications have to be translated first. This procedure is called localization or internationalization. So, what you need to do is to localize the content of your notifications. And I’m about to show you how.</blockquote><h3>Dynamic localization</h3><p>Notification Service Extension plays a key role here. How does it work? Simply put, it allows you to implement changes in payload before the system displays a notification. This solution enables you to<strong> replace the payload with the one that is dedicated to localization (or language) set in the system </strong>or in the app itself.</p><h3>Setting the same language both for the app and the system</h3><p>It’s easy when the translation of the app is based on a native solution. This means it relies on the language settings defined in the iOS system. In such a case you only need to use the Locale class, so you could retrieve a list of preferred languages or find out what is the system language.</p><h3>How to set a different language than the one the system uses?</h3><p>It takes more effort when you want to enable setting a different language of the app than the one defined in the system. That’s because the extension doesn’t have direct access to the app (and its sandbox) and vice-versa. What can you do in such a case?</p><p>Another system solution comes to the rescue: App Groups. Precisely, <strong>App Group Shared Container. It is a place that can be accessed by the extensions and apps from the same development team.</strong> In other words, those that use the same developer certificate for signing the code. In a shared container you can store database files (e.g., CoreData), or UserDefaults, among others.</p><blockquote>For the purpose of this article, I used UserDefaults, because in my opinion this solution doesn’t require a lot of additional knowledge. Moreover, I don’t find it necessary to shoot the cannon (i.e., using a database, such as CoreData) at the sparrow (to enable storing ID of a chosen language).</blockquote><p>I assume you already have a developer certificate on the Apple Developer platform. If not, create it <a href="https://developer.apple.com/support/certificates/">here</a>, before I move on to the first stage.</p><h3>Configuration of the environment</h3><p><em>App Identifiers, Profiles, App Groups</em></p><h3>General remarks</h3><p>First of all, you need profiles from the Apple Developer platform to run this project. Remote Push Notifications don’t work on simulators, so you need a physical device.</p><p>Another issue concerns creating app profiles and IDs. You probably know how to move within the Apple Developer platform, so I won’t delve into details when it comes to generating App Identifiers or App Profile (in this exact order). But if you have doubts, check out the <em>Maintain signing assets</em> section <a href="https://help.apple.com/xcode/mac/current/">here</a>.</p><h3>ID registration</h3><p>Begin with the registration of App Identifiers for the app and the extension. The identifier for the app should have two Capabilities added:</p><ul><li>Push Notifications,</li><li>App Groups.</li></ul><p>The identifier for the extension requires only one capability: App Group.</p><h3>Container registration</h3><p>To enable the app and the extension to communicate with one another, there must be a link (App Group), namely a shared container. But first, you need to register it in Apple Developer platform. Here’s a short instruction on how to do it:</p><ol><li>Log in to the Apple Developer platform.</li><li>Go to <em>Certificates, IDs &amp; Profiles.</em></li><li>Move to <em>Identifiers.</em></li><li>Click the + symbol. You can find it in the upper part of the website, next to the headline of a section.</li><li>Select <em>App Groups</em> from a list and fill out the empty fields.</li></ol><p>You can type any names you like, but for the Identifier, it’s a good practice to use a template below:</p><h4><strong>group + reverse domain + app name</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u6u5dAWizme4fPPa.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*ubTTx8XSE1CnA1np.png" /></figure><p>When you already have a group, you can add it as a capability for an App Identifier of the app and the extension. There’s an <em>Edit</em> button in the Capabilities section, next to App Groups. Click it and check the group created before. You have to perform the same action for the Identifier of the app and the extension. In the end, generate developer profiles for them.</p><h3>Implementation</h3><h3>App group registration</h3><p>First of all, create a new project in Xcode. If you don’t want to write the code yourself, use the resources from <a href="https://github.com/lukasz-szyszkowski/localized-push-notifications-demo">Github</a>.</p><p>Next, follow the steps below:</p><ol><li>On Xcode, check the target of the main application.</li><li>Check<em> Signing and Capabilities.</em></li><li>Uncheck <em>Automatically manage signing</em> (if this option is checked).</li><li>In <em>Provisioning Profile </em>section, select the app profile you’ve generated before.</li><li>In the upper left corner, click <em>Capability</em>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/0*ltIi50t26ksGfZiG.png" /></figure><p>6. Select <em>App Groups</em> from a list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MjjakQi1nBIANJNi.png" /></figure><p>7. Check the group you’ve created before. If it’s not on the list, click a <strong>+</strong> symbol. Then enter the ID of a group you’ve created in a previous section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pb-93-JhWsJe4SYU.png" /></figure><p>For example, in my case it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/0*apS5o2nhIK4hmP_U.png" /></figure><h3>Adding the extension</h3><p>When you have a registered group for the app, you can finally create what you want the most: <strong>an extension that allows you to modify a notification.</strong></p><p>In a <em>Target</em> column click a <strong>+</strong> symbol. You can find it in the bottom left corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*0oQ8Wn81fW2G2aX6.png" /></figure><p>Next, in a search tab enter <em>Notification Service Extension.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WYkPc8EGvTPyomEl.png" /></figure><p>Click <em>Next</em> and enter the name of the extension. Again, you can type anything you want there, but it’s best when the name is associated with a role this extension performs. Otherwise, you won’t be able to tell at the first glance what it is for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IfIGPhshU6v4Vg2P.png" /></figure><p>Click <em>Finish</em>. Then you’ll be asked whether you want to activate the extension. Choose the <em>Activate</em> option, and Xcode will generate the files you need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*M3EQiJTR8_JHWE6H.png" /></figure><h3>Setting up the Provisioning Profile &amp; App Group</h3><p>Now you have the extension, but you still need to set a Provisioning Profile and an App Group, just like you did before, with the main app.</p><ol><li>Check the target of an extension.</li><li>Click <em>Signing</em> <em>and</em> <em>Capabilities</em> tab.</li><li>Uncheck <em>Automatically manage signing (</em>if this option is checked).</li><li>From <em>Provisioning</em> <em>Profile </em>section, select the profile for the extension that you’ve generated before.</li><li>In the upper left corner, click <em>Capability</em>, and then select App Groups from a list.</li><li>Check the list you created. If it’s not on a list, click a <strong>+</strong> symbol and enter the same group ID that you’ve introduced for the main app.</li></ol><p>At this point, it’s best to make sure whether the app builds and installs itself on a device. Additionally, check if you can receive the messages. For this purpose, add a registering code for the remote notification application in <em>AppDelegate.swift.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a559cb7fd6cd3a2b8c30ba5de0127f2/href">https://medium.com/media/3a559cb7fd6cd3a2b8c30ba5de0127f2/href</a></iframe><p>Now, after the registration, it’s time when you can print your token in the console. This function should be added to <em>AppDelegate.swift </em>file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6f4d67cc7cb696a5b3d465ca833f096/href">https://medium.com/media/b6f4d67cc7cb696a5b3d465ca833f096/href</a></iframe><p>Start the app and agree on receiving the notifications. To check whether they work correctly, I use the Push Hero app, available on App Store. It’s easy to use but paid.</p><p>If you look for a free solution, use an open-source app Knuff or create your own script for sending the messages. It’s entirely up to you. What’s important, payload needs to include the mutable-content: 1 field. Without this parameter, the extension cannot process the notifications.</p><p>Below you can see the example of payload:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc5b689f45168b270fd4f5bdbe01baef/href">https://medium.com/media/cc5b689f45168b270fd4f5bdbe01baef/href</a></iframe><p>If everything went according to plan, you should see a notification like this one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8qNvf3_-2ljU3XX3.jpg" /></figure><p>The title includes the word <em>[modified]. </em>It means the extension works correctly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d62db60b73f68aa96b8e9de4786c06bb/href">https://medium.com/media/d62db60b73f68aa96b8e9de4786c06bb/href</a></iframe><p>And finally, the moment you were waiting for — setting up the languages. To make managing the chosen language easier, I created a helper class: <em>LanguageController.swift</em><strong><em>. </em>It is important that its target would be both the app and the extension because you’ll use this class in two places.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2825cfaa81852eceb5e673586b6f3b03/href">https://medium.com/media/2825cfaa81852eceb5e673586b6f3b03/href</a></iframe><p>A payload for the notifications will look similar to the one below. Again, there are no rules dictating how to choose names, but remember that all customized keys should be defined at the <em>aps</em> key level.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d70682e0772ef511cc7a84ae3c2020af/href">https://medium.com/media/d70682e0772ef511cc7a84ae3c2020af/href</a></iframe><p>In a console, you may see a message like this:</p><p>[User Defaults] Couldn&#39;t read values in CFPrefsPlistSource&lt;0x281ced500&gt; (Domain: group.com.holdapp.localized-apns-demo, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd.</p><p>In such a case, just ignore it. If you want to know more, you’ll find the information <a href="https://stackoverflow.com/questions/38275395/failed-to-read-values-in-cfprefsplistsource-ios-10/39923879#39923879">here</a>.</p><p><strong>This is the code that enables you to download the message:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd97d585a06ab081e217ee3809087503/href">https://medium.com/media/fd97d585a06ab081e217ee3809087503/href</a></iframe><p>With this code, you can implement the support for your notifications in a class that handles the extension.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5f0d7e77c27e649312239ae2106a497/href">https://medium.com/media/d5f0d7e77c27e649312239ae2106a497/href</a></iframe><p>Keep in mind that even if for some reason you won’t be able to retrieve the translation from a payload, the system will display content from the <em>aps</em> object. That’s why it should be updated every time you send a message.</p><p><strong>Notifications play an important role in marketing communication and allow you to keep the users up-to-date</strong>. They also encourage them to open the app more often.</p><p>If you develop a commercial app that works on several markets, try out this solution. Download the entire code from <a href="https://github.com/lukasz-szyszkowski/localized-push-notifications-demo">Github</a> and use it in your project.</p><p>—</p><p><em>This article was originally published on </em><a href="https://www.holdapp.com/blog/how-to-send-ios-notifications-in-different-languages?utm_source=Medium&amp;utm_medium=Article&amp;utm_campaign=Link"><em>Holdapp’s blog.</em></a><em> Visit our website and learn more or contact us, if you need a team that will develop your app.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72bd4035dbbf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-send-ios-notifications-in-different-languages-guide-to-dynamic-localization-72bd4035dbbf">How to Send iOS Notifications in Different Languages? Guide to Dynamic Localization</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>