Latest 1.0.9
License LPGL 2.1
Platforms ios 8.0
Dependencies Liferay-iOS-SDK

Liferay Mobile SDK logo

Liferay Push for iOS

Build Status


This library is a CocoaPods subspec of the Mobile SDK for iOS. This library becomes available once you install the Mobile SDK as a dependency. See the Mobile SDK documentation to learn how to include it as a dependency to your project.


Registering a Device

To receive push notifications, your app must register itself to the portal first. On the portal side, each device is tied to a user. Each user can have multiple registered devices. A device is represented by a device token string.

Read Apple’s documentation to learn how to get the device token. This tutorial is also useful to learn how Apple Push Notification works.

Once you have the device token, you can register the device to the portal by calling:

#import "Push.h"

LRSession *session = [[LRSession alloc] initWithServer:@"http://localhost:8080" username:@"[email protected]" password:@"test"];

[[Push withSession:session] registerToken:deviceToken];

Now each time the portal wants to send a push notification to the user [email protected], it looks up all registered devices for the user (including the one just registered) and sends the push notification for each deviceToken found.

Since all operations are asynchronous, you can set callbacks to check if the registration succeeded or an error occurred on the server side:

[[[[Push withSession:self.session]
    onSuccess:^(NSDictionary *device) {
        NSLog(@"Device was registered!");
    onFailure:^(NSError *e) {
        NSLog(@"Some error occurred!");

The onSuccess and onFailure blocks are optional, but it’s good practice to implement both. By doing your app can persist the device token or tell the user that an error ocurred.

You should note that the Push class is a wrapper for the Mobile SDK generated services. Internally, it calls the Mobile SDK’s LRPushNotificationsDeviceService_v62 class. While you can still use LRPushNotificationsDeviceService_v62 directly, using the wrapper class is easier.

Once your device is registered, your app must be able to listen for notifications. Apple’s developer documentation shows how to implement this in your app.

Sending Push Notifications

There are many ways to send push notifications from Liferay Portal. See the Liferay Push documentation for more details. Alternatively, you can send push notifications from your iOS app. Just make sure the user has the proper permissions in the portal to send push notifications.

NSDictionary notification = @{
    @"message": @"hello!"

[[Push withSession:session] sendToUserId:123 notification:notification];

In this code, the push notification is sent to the user specified by sendToUserId. Upon receiving the notification, the portal looks up all the user’s registered devices (both Android and iOS devices) and sends notification as the body of the push notification.

Unregistering a Device

If you want to stop receiving push notifications on a device, you can unregister it from from the portal with the following code:

[[Push withSession:session] unregisterToken:deviceToken];

Users can only unregister devices they own.

Latest podspec

    "name": "Liferay-Push",
    "module_name": "LRPush",
    "version": "1.0.9",
    "summary": "Liferay Push iOS Client",
    "homepage": "",
    "license": {
        "type": "LPGL 2.1",
        "file": "copyright.txt"
    "authors": {
        "Bruno Farache": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "1.0.9"
    "source_files": "{Core,Service}/**/*",
    "dependencies": {
        "Liferay-iOS-SDK": [

Pin It on Pinterest

Share This