GetSocial Notifications on iOS

Prerequisite

Setup iOS Push Notifications

Generate Push Notification Certificate

To enable push notifications in your iOS application, go to “Capatibilities” tab in your target configuration in XCode and enable “Push Notification”.

On Apple Developer Portal:

  1. Open Apple Developer Portal;

  2. Log into your account;

  3. Open “Certificates, Identifiers & Profiles”;

  4. Find “App IDs” in “Identifiers” section and find your application;

  5. Click “Edit” and scroll to “Push Notifications” configurations;

  6. Click “Create Certificate…” for Development and Production.

  7. Follow the instructions how to create certificate and download it.

In your .entitlements file you should enter “development” or “production” value for “APS Environment” key, for Development and Production builds respectively.

Export Server .p12 Certificate

Double click on downloaded .cer file (your certificate), it will add it to your Keychain Access and open. Click on “Certificates” section, find your certification, and export it with clicking “Export Apple Development/Production iOS Push Services”, create a password for your certificate and save it somewhere on the disk.

Do it for both Production and Development certificates.

Configure Push Notification on the Dashboard

  1. Login to the GetSocial Dashboard.
  2. Go to the “App settings” section → “Notifications” tab.
  3. Enable iOS notifications by clicking on the switch and upload .p12 certificates from the previous section.
  4. Select what kind of notifications users will receive:

    GetSocial Dashboard - Notifications Type

  5. Select “Sandbox” if your application using development PN, or “Production” for development.

  6. Press “Save” button in the bottom right corner.

Warning

Be careful with configuration of your APS Environment, if you’re using “development”, you need to sign your application with Development provisioning and choose “Sandbox” in “Enable Certificate” on GetSocial Dashboard notification configurations.

Enable/disable GetSocial Notifications on the Client Side

By default GetSocial SDK automatically register at push server and user will start receiving push notifications.

To prevent auto registration and register for push notifications manually:

  1. Add autoregister-push parameter to getsocial.sh in Build Phases section:

    1
    getsocial.sh --app-id=[GetSocial App Id] --autoregister-push=false
    
  2. To start receiving GetSocial push notifications call:

    1
    [GetSocial registerForPushNotifications];
    

To enable push notifications, just remove the autoregister-push parameter from getsocial.sh or set its value to true.

If you’re not using GetSocial iOS Installer Script check how to disable auto registration for push notifications in the Manual Integration Guide.

Handle Click on Push Notifications

GetSocial UI

If you’re using GetSocial UI, our respective view will be opened on click on push notifications: if someone liked your activity or commented under your activity, this activity will be shown on application start.

Important

If GetSocial View is opened automatically by GetSocial UI, you can not set custom title, UiActionHandler, action button handler etc. In this case we recommend you to override default behavior and open GetSocial View by yourself.

Notification Action Handler

To handle notification click in your code, we provide GetSocialNotificationActionHandler, you can set it in application:didFinishLaunchingWithOptions: method of your AppDelegate:

1
2
3
4
[GetSocial setNotificationActionHandler:^BOOL(GetSocialNotificationAction *action) {
    BOOL isHandled = [self processNotificationAction:action];
    return isHandled;
}];

This method will be called if your UIApplication was started from GetSocial notification click.
You return a BOOL: YES, if notification is handled by your own, or NO if not, so it will be handled by our library.
For example, if you want to prevent of showing GetSocial Activity Feed UI on notification click:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
- (BOOL) processNotificationAction: (GetSocialNotificationAction *)action {
    switch (action.action) {
        case GetSocialNotificationActionOpenActivity: {
            // add custom logic here
            NSLog(@"Activity action received");
            return YES;
        }
        default:
            return NO;
    }
}

In this case you’re showing something you’d want to show about the activity and GetSocial UI won’t be shown.

Tip

If you are not using GetSocial UI, we recommend to handle notifications by yourself - better user experience would be to react to notification actions.

Give us your feedback! Was this article helpful?

😀 🙁