Git Product home page Git Product logo

pushstarter-ios-app's Introduction

pushstarter-ios-app Build Status

Swift version of PushStarter iOS app is available here.

ObjC/Cocoapods of PushStarter iOS app is available here.

Author: Corinne Krych
Level: Intermediate
Technologies: Objective-C, iOS, RHMAP Summary: A demonstration of how to include basic push functionality with RHMAP. Community Project : Feed Henry Target Product: RHMAP
Product Versions: RHMAP 3.7.0+
Source: https://github.com/feedhenry-templates/pushstarter-ios-app
Prerequisites: fh-ios-sdk : 3.+, Xcode : 7.2+, iOS SDK : iOS7+

What is it?

The PushStarter project demonstrates how to include basic push functionality using fh-ios-sdk and Red Hat Mobile Application Platform. The developer should:

  • enable push notifications in the iOS app within RHMAP,
  • enter required certificate,
  • send test notification via RHMAP studio Push tab. The iOS app catches the notification and displays them as a list.

If you do not have access to a RHMAP instance, you can sign up for a free instance at https://openshift.feedhenry.com/.

How do I run it?

RHMAP Studio

This application and its cloud services are available as a project template in RHMAP as part of the "Push Notification Hello World" template.

Local Clone (ideal for Open Source Development)

If you wish to contribute to this template, the following information may be helpful; otherwise, RHMAP and its build facilities are the preferred solution.

Build instructions

  1. Clone this project

  2. Populate PushStarter/fhconfig.plist with your values as explained here.

  3. Open PushStarter.xcodeproj

  4. Run the project

How does it work?

FH registers for remote push notification

In PushStarter/AppDelegate.m you register for notification as below:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  [FH pushRegister:deviceToken andSuccess:^(FHResponse *success) {
    NSNotification *notification = [NSNotification notificationWithName:@"success_registered" object:nil];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
    NSLog(@"Unified Push registration successful");
  } andFailure:^(FHResponse *failed) {
    NSNotification *notification = [NSNotification notificationWithName:@"error_register" object:nil];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
    NSLog(@"Unified Push registration Error: %@", failed.error);
  }];
}

Register FH to receive remote push notification with success [1] and failure [2] callbacks.

FH receives remote push notification

To receive notification, in PushStarter/AppDelegate.m:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    NSLog(@"UPS message received: %@", userInfo);
}

iOS9 and non TLS1.2 backend

If your RHMAP is depoyed without TLS1.2 support, open as source PushStarter/PushStarter-Info.plist add the exception lines:

  <key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
  </dict>

pushstarter-ios-app's People

Contributors

corinnekrych avatar edewit avatar jasonmadigan avatar matzew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.