Latest 1.2
Homepage https://github.com/baspellis/WCParsePush
License MIT
Platforms ios 7.0, requires ARC
Dependencies KSReachability
Authors

Lightweight Push Notifications with Parse.com

Description

This small library provides simple interface to the Parse Push Notification Service without the need to include the full Parse iOS SDK. It inlcudes:

  • Device installation registration
  • Channel subscribe/unsubscribe
  • Async and synchoronous save methods
  • Save eventually also after app restart

Installation with CocoaPods

Add the following to your podfile

pod "WCParsePush", "~> 1.1"

Getting started

Add the following to your Application Delegate implementation:

Objective-C:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Setup Push Notifications
    [WCParsePushInstallation setApplicationId:@"<YOUR-APP-ID>" clientKey:@"<YOUR-CLIENT-KEY>"];

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];

    return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    [[WCParsePushInstallation currentInstallation] setDeviceTokenFromData:deviceToken];
}

Swift:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    // Setup Push Notifications
    WCParsePushInstallation.setApplicationId("<YOUR-APP-ID>", clientKey: "<YOUR-CLIENT-KEY>")

    let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories: nil)
    application.registerUserNotificationSettings(settings)
    application.registerForRemoteNotifications()

    return YES;
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    let pushInstallation = WCParsePushInstallation.currentInstallation()
    pushInstallation.setDeviceTokenFromData(deviceToken)
}

Swift 2.0:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    // Setup Push Notifications
    WCParsePushInstallation.setApplicationId("<YOUR-APP-ID>", clientKey: "<YOUR-CLIENT-KEY>")

    let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    application.registerUserNotificationSettings(settings)
    application.registerForRemoteNotifications()

    return YES;
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    let pushInstallation = WCParsePushInstallation.currentInstallation()
    pushInstallation.setDeviceTokenFromData(deviceToken)
}

Then to add a channel subscription

Objective-C:

[[WCParsePushInstallation currentInstallation] addChannel:@"Channel"];
[[WCParsePushInstallation currentInstallation] saveEventually];

Swift:

let pushInstallation = WCParsePushInstallation.currentInstallation()
pushInstallation.addChannel("Channel")
pushInstallation.saveEventually()

To reset the badge number

Objective-C:

[[WCParsePushInstallation currentInstallation] setBadge:0];
[[WCParsePushInstallation currentInstallation] saveEventually];

Swift:

let pushInstallation = WCParsePushInstallation.currentInstallation()
pushInstallation.badge = 0
pushInstallation.saveEventually()

Contact

Bas Pellis

License

WCParsePush is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "WCParsePush",
    "version": "1.2",
    "summary": "Lightweight Push Notifications with Parse.",
    "description": "This small library provides simple interface to the Parse Push Notification Service without the need to include the full Parse iOS SDK. It inlcudes:nn* Device installation registrationn* Channel subscribe/unsubscriben* Async and synchoronous save methodsn* Save eventually also after app restart",
    "homepage": "https://github.com/baspellis/WCParsePush",
    "license": "MIT",
    "authors": {
        "Bas Pellis": "[email protected]"
    },
    "source": {
        "git": "https://github.com/baspellis/WCParsePush.git",
        "tag": "1.2"
    },
    "social_media_url": "https://twitter.com/baspellis",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "WCParsePush",
    "dependencies": {
        "KSReachability": [
            "~> 1.4"
        ]
    }
}

Pin It on Pinterest

Share This