How to handle iOS Push Notifications in Different language - ios

I am working on an app in which, I have implemented Push Notifications. Now I have to give support for Multiple language for Push notifications.
Please suggest whether, Localization for push notifications should be on App side or Server side.
And How to handle the language of push displayed on Banner when app is not running?
Thanks In Advance

This is an old question but it deserves a new answer.
Localized push notifications can be solved either server side or in the app.
To send localized notifications server side requires that the server knows the users language preference and like aronspring suggested, a good time to do that is when registering the push token.
To do it locally on the phone you need to supply all possible notifications and their translations in the app bundle Localizable.strings file. The server would then instead of sending the text to be displayed, send the key to the corresponding translation in Localizable.strings.
Example aps payload:
"aps" : {
"alert" : {
"loc-key" : "SOME_MESSAGE"
}
}
For a better explanation read more here: Local and Remote Notification Programming Guide

Like you've just pointed out, in the scenario when your app is not running the OS will receive the notification and not run any code within your app to translate them, and will display them as they are received. So they will need to be translated server side before being sent. The app shouldn't have to worry about what language they are sent in - no code needs to be written app side for this.
It might be an idea to store the device locale when you register the push token to known what language the device is set to.

Related

Handle Push Notification when the App is off, or without opening the App at all - iOS

I'm building a Push Notification platform with Amazon SNS, using Amazon Cognito and other Amazon AWS tools, so far working flawlessly.
But my App is multi-language, so I'm trying to send just 1 single push message with a dictionary within the payload, this dictionary will contain an array with all the languages that I'm supporting.
So I just don't want to simply handle the message, what I'm intending is to do not show the push message at all before selecting the proper language that should appear to the user... With the App killed or not.
So my Q:
Is this seems possible?
What approach do you suggest to achieve this?
Thank you all very much.
No (when the user kills the app or when backgroundfetching is turned off, no notifications will reach your app).
Look into how to localize pushnotifications on apple's developer website. You can acieve exactly what you want by letting the system do the localization.
See the applicable keys in the push payload: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html
There are some limitations of APNS as follows:
didReceiveRemoteNotifications delegate execute only if the application is in either foreground or background.
If the application is terminated/suspended by either user or OS then notification will be displayed in notification centre but the respective delegate would not get called.
Set both Background fetch and Remote notifications enabled in Background modes from project setting.
Use application:didReceiveRemoteNotification:fetchCompletionHandler: delegate instead of didReceiveRemoteNotifications.
Hope this will help you.

Control which iOS notifications to display

We have iOS push notifications configured and running. However, we would like the user to select which categories are interesting to receive and which are not important and would like to omit receiving those notifications.
Is there any way to do this through Apple push notification itself rather than through the server sending the notifications? (We can change the sent JSON). Can the iPhone send which categories it would like to receive and which are not needed by registering them to Apple? Other choice, can we interrupt the push notification before being shown and decide whether it should be shown or not through a delegate? So far, I can't find an available method to do either.
Any help is appreciated
The short answer is not from the client side. If you want a solution that works 100% of the time you will need to do something on a server which only sends the types of push notifications the user subscribes to.
If your App is in background there is no concept of "categories" of PUSH notifications and you have no control over if they show up in the notification center.
You can examine inbound push when the App is in the foreground and decide on the basis of some meta data to display or not, but that is not a 100% solution.

Is it possible to send push notification from one iOS app to another iOS app?

I am not very familiar with push notifications. But is it possible to send push notification from one app to another? I know you need a server to send notifications but is it possible implement that in an app.
Short answer: No, pushes are sent from a server to a server.
Long answer: Of course, it's not common practice, but lots of fun.
To send out a push notification to an Apple device, you will need to connect with the APNS server and then send your notification in data format. Although this is usually done from a server, it can just as well be done from an iPhone or iPad.
If you want to get going yourself, I recommend reading all the documentation Apple provides on this topic (start here). Everything you need to know is in there, but you will need to pay attention to the details in order to get this to work.
An easier way to get going is by using NWPusher. This is an iOS framework that provides all the tools you need to push from iOS to iOS. It even includes an iOS demo app that does this:
NWPusher - Push from iOS
Just a small warning: In order to push from iOS, you will need to include the push certificate and private key in the app bundle. This is not a secure place to keep such a private key and you definitely don't want your app's push certificate to leak.
Enjoy!

Apple push notification Vs. Parse

i have an app and i'm thinking about implementing push notifications in it. however, i want to use remote notifications. i've tried Parse's push notification service and it's great and works well. You can type any text you want to inform your users about and just press send in order to be delivered to all your App users. On the other hand, i don't know if Apple has any such service that can facilitate the process of sending remote notifications. so which is better to stick to, Apple or Parse? and can i have the same service as Parse from Apple?
Yes, you can get the same services as Parse. You have to build your own server that will talk with Apple APNS. Just for example sending a push notification from your own server without using parse is here.
I didn't understand what are you trying to ask.
You can use Apple push notification service for sending remote content. With Any content related to your App.
Check RemoteNotifications for details. Parse is also using the Apple's push notification service.
Edit: For implementing your own servers for push notification check this tutorial : Push Notification Services

How would one determine which apple push notification server (APNS) is in use, from iOS application

I wish to include in my registration message to our server, a flag as to which APNS server is being used. sandbox or production. I wish to do this so that my code can simply look up the device token and notification server from the table of devices, so that continuing development can coexist with live devices.
The application does, in development, register properly, linking a customer ID in our system to the token string from the phone.
However, this does not allow me to determine programatically from our server which push notification server to use.
I'm not sure if I have your question right, but as per Apple's doc Local and Push Notification Programming Guide: The Notification Payload
Providers can specify custom payload values outside the Apple-reserved
aps namespace.
So all you need to do is craft your custom payload to indicate which server the notification was pushed from, and read it when it gets to the App.

Resources