ICQ Mobile for iOS version 2.6 and push notifications
The main innovation of the new version of the ICQ client for iPhone / iPod / iPad is support for the Push-notification mechanism, and we decided to talk about them a little more from the point of view of the developer. Perhaps this information will be useful to authors of alternative clients for iOS.
We will not describe for a long time what Push notifications are and how they should be used, the author of the technology, Apple, did this much better than we could do. Documentation on the Apple website .
Let's dwell on how this works in ICQ.
We are now reporting two types of events: authorization requests and message sending. (expanding this list in the future is unlikely).
A user who subscribes to push notifications is considered to be online, even if he has left ICQ. It’s not so important for us that the client is not running, but it’s crucial that the message will be read instantly. In the settings, you can specify how long this state will remain in case of user inactivity. The default value is day.
Messages received via push notifications are not considered read, but remain as undelivered offline messages on the server, i.e. they will be delivered to the first launched ICQ client. This should be important for those users who use the application on the phone as a means of notification, but prefer to talk from a computer. Running any other client with the same UIN displays the iPhone client offline - this is done so that messages do not arrive immediately on two devices and with two sound signals.
We are not completely sure that the whole logic of the two previous paragraphs is perfect, perhaps some changes will be made to it based on statistics and user reactions.
As for the technical side of the matter, everything is quite simple and can be implemented by alternative clients without significant effort.
When creating or changing session parameters, specify the parameters from the table below
Boolean | mobile | Mobile Session Flag |
Notification mode | notifyMode | Notification mode (default value is “disabled”) |
String | iPhoneDevToken | Token devices (hex format) |
String | iPhoneBundleId | Bundle Application ID |
String | iPhoneSound | The string that the server will send in notifications in the “sound” parameter. Optional |
String | iPhoneLocKey | The string that the server will send in notifications in the “loc-key” parameter. Optional |
String | iPhoneActionKey | The string that the server will send in notifications in the “action-loc-key” parameter. Optional |
Boolean | iPhoneBadge | The string that the server will send in notifications in the “badge” parameter. Optional |
String | iPhoneLocArgs | Fields for notifications. The fields that the application wants to receive in notifications are listed with a comma. Supported fields are “srcName”, “srcId”, “destName”, “timestamp”, “message”. |
Integer | sessionTimeout | The length of the session before disconnecting (in seconds). |
All fields except Notification mode do not seem to require explanation, and Notification mode is an enumerated type with possible options.
Disabled | Disconnected |
sendOnlyOne | Send only one |
sendOnePerConversation | Send no more than one from each contact |
applePushNotification | Send all notifications |
I pay extra attention to the mobile field, if it is filled, then this allows you to display the corresponding icon in the contact list of your friends.
Everything, now it remains to exit the client to start receiving push notifications.
We send 4 types of notifications, see examples below.
1. One message: {"aps": {"alert": {"loc-key": "IM2", "loc-args": ["111111", "222222", "some_text_here"]}, "badge" : 1, “sound”: “IM”}}
111111 - sender UIN
222222 - receiver UIN
some_text_here - message text
2. Several messages: {"aps": {"alert": {"loc-key": "New Messages" , "Loc-args": ["5"]}, "badge": 5, "sound": "eventSound_ReceiveIm.wav"}}
3. One authorization request: {"aps": {"alert": {"loc-key": "AR1", "loc-args": ["111111", "222222", "parparon5", "John", "Johnson"]}, "badge": 1, "sound": "eventSound_ReceiveIm.wav"}}}
111111 - UIN of the recipient
222222 - UIN of the sender
parparon5 - Nickname of the sender
John - Name of the sender
Johnson - Surname of the sender
4. Several authorization requests: { "Aps": {"alert": {"loc-key": "AR2", "loc-args": ["2"]}, "badge": 2, "sound": "eventSound_ReceiveIm.wav"}}
It seems that they do not require additional explanations. However, if they demand, we are always ready to give them.
PS: no, we do not plan to switch to XMPP, all my thoughts on this subject can be found in the comments to any previous post about ICQ.
PPS: yes, many use the official client for the iPhone, even in the Russian AppStore the original ICQ is higher than any alternative. And, than any client supporting arbitrary xmmp, too.
PPPS: ICQ Mobile on the AppStore