The main innovation of the new version of the ICQ-client for iPhone / iPod / iPad is the support of the push-notification mechanism, and we decided to talk about them in more detail from the developer's point of view. Perhaps this information will be useful to the authors of alternative clients under 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 it much better than we could have done.
Documentation on the Apple site .
')
Let us dwell on how this works in ICQ.
Now we notify about two types of events: authorization requests and sending messages. (expansion of this list is unlikely in the future).
A user who subscribes to Push Notifications is considered to be online, even if he is logged out of ICQ. It is not so important for us that the client is not running, but in principle that the message will be read instantly. In the settings you can specify how long this state will be maintained in case of inactivity of the user. The default 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 running 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 at once on two devices and with two sound signals.
We are not completely sure that the entire logic of the two previous paragraphs is perfect, perhaps some changes will be made to it based on the statistics and user reactions.
As for the technical side of things, everything is quite simple and can be implemented by alternative clients without significant efforts.
When creating or changing session parameters, you must specify the parameters from the table below.
Boolean | mobile | Mobile Session Flag |
Notification Mode | notifyMode | Notification Mode (default is “disabled”) |
String | iPhoneDevToken | Token devices (hex format) |
String | iPhoneBundleId | Application Bundle ID |
String | iPhoneSound | The string that the server will send in the notifications in the “sound” parameter. Optional to fill. |
String | iPhoneLocKey | The string that the server will send in the notifications in the “loc-key” parameter. Optional to fill. |
String | iPhoneActionKey | The string that the server will send in the notifications in the “action-loc-key” parameter. Optional to fill. |
Boolean | iphonebadge | The string that the server will send in the notifications in the “badge” parameter. Optional to fill. |
String | iPhoneLocArgs | Fields for notifications. Comma-separated lists the fields that the application wants to receive in notifications. Supported fields are “srcName”, “srcId”, “destName”, “timestamp”, “message”. |
Integer | sessionTimeout | The length of the session before disconnecting (in seconds). |
All fields except Notification mode seem to require no explanation, and Notification mode is an enumerated type with possible options.
Disabled | Disabled |
sendOnlyOne | Send only one |
sendOnePerConversation | Send no more than one from each contact |
applePushNotification | Send all notifications |
I pay additional attention to the mobile field, if it is filled, this allows you to display the corresponding icon in the contact list of your friends.
Everything, now it is necessary to leave 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's UIN
222222 - Recipient's 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 - Recipient's UIN
222222 - Sender's UIN
parparon5 - Sender's nickname
John - Sender Name
Johnson - Last Name of the Sender
4. Multiple authorization requests: {"aps": {"alert": {"loc-key": "AR2", "loc-args": ["2"]}, "badge": 2, "sound": "EventSound_ReceiveIm.wav"}}
It seems, and they do not require additional explanation. However, if required - we are always ready to give them.
PS: no, we are not planning on switching to XMPP, all my thoughts on this subject can be read 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 one. And, than any client supporting arbitrary xmmp, too.
PPPS:
ICQ Mobile on the AppStore