Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Want a Uber-like on-demand app? Add pubsub messaging functionalities without having to worry about backend!

desiretech/lompang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lompang SDK

This repository contains the API that powers the iOS carpooling app, Lompang. It's a set of pubsub messaging functionalities which iOS developers can call from their Obj-C codes. Backend is conveniently handled for you.

Below scenerio depicts 2 devices connecting and then joining Group A. Presence of User A and B are automatically broadcasted everyone in the group. More scenarios illustrated below.

Join

DEFINITIONS

Before venturing further, some basic definitions need to be established first.

Groups

Equivalent of rooms and channels in standard pubsub terminology. A Group can contain a mixture of Posts and Users. Once a User is subscribed to a Group using the join or listen method, Users and Posts packets are pushed through the socketReceivedDict delegate method.

Users

When connecting to Lompang SDK for the first time, a device will be allocated a unique identifier user that identifies a User by device and app. This unique identifier stays unchanged across sessions, even after an app uninstall. Below snippet shows a sample User package that is sent through the socketReceivedDict delegate method. group refers to the Group from which the User package is pushed from. timestamp refers to the Unix timestamp in milliseconds the User was last seen in the Group. timestamp= 0 indicates User is currently online. userload is the custom payload that is attached to the User.

@@@ socketReceivedDict: {
    group = ABC;
    timestamp = 0;
    type = user;
    user = "7B9194EA-35D4-4BB7-89AE-2FBFD386AA60";
    userload =     {
        a = A;
        b = B;
    };
}
Posts

A User can post a message to a Group via the post method. Below snippet shows a sample Post package that is sent through the socketReceivedDict delegate method. group is the Group that User posted the Post to. pid is the custom identifier that a developer uses to uniquely identify the Post. pidload is the custom payload attached to the message. timestamp is the Unix timetamp in milliseconds when User posted the Post. user is the User that posted the Post.

@@@ socketReceivedDict: {
    group = ABC;
    pid = PID;
    pidload =     {
        a = A;
        b = B;
    };
    timestamp = 1409876031645;
    type = post;
    user = "45DC9C41-6047-4871-9AF4-357E8E4425A3";
}

SCENARIOS

Below illustrates the listen method. Note that User B is unaware of User A's presence in the group. Compare this with the previous scenario. Listen

Disconnect events are also broadcasted to Users in the Group. Illustrated below, User B is somehow disconnected at Stage 4. This change in presence is broadcasted to User A. Note that timestamp of User B changed from 0 in Stage3 to 1409876031645 in Stage 5. Timestamp= 0 indicates User B was online at Stage 3. Timestamp= 1409876031645 indicates User B was last seen at Sep5, 2014, 12:13:51am UTC. Disconnect

Method update changes the userload attached to User B. This change is then broadcasted to all Groups that User B has join-ed. Update

User A posts a message with custom payload pidload to Group A. Post is then broadcasted to everyone in Group A. Upon receipt, a developer is expected to issue out a unpost command to remove the post. Otherwise Post A will continue to be dispatched out to all Users entering the Group. Post

INSTRUCTIONS

  • Generate APNS certificate from Apple.
  • Make sure certificate is in .p12 extension and is NOT password protected.
  • Not sure how? Here for detailed instructions.
  • Go to lompang.com/sdk.html
  • Key in your email address
  • Upload your .p12 APNS cert that is NOT password protected
  • Indicate type of certificate, whether it is Sandbox or Production
  • Follow instructions from email and you should receive your token key
  • Please keep your token key. You will need to add it to your codes later
  • Create a new xCode project
  • Change the architecture to armv7

![Add Files](/images/changeArchitecture.png) * Download the 3 files from [Lompang folder](https://github.com/ngzhongcai/lompang/tree/master/Lompang) in Github * Lompang.h, libLompang.a, lompang.mom * Drag and drop the 3 files under Frameworks folder group * When prompted, select "Copy items into destination group's folder" * Link CoreData and SystemConfiguration, Foundation, CoreGraphics and UIKit libraries to your binary
![Add Files](/images/addfiles.png) * In [AppDelegate.h](https://github.com/ngzhongcai/lompang/blob/master/saas/AppDelegate.h) * ```#import "Lompang.h"``` * ```@class Lompang;``` * ```@property (strong, nonatomic) Lompang *lompang;``` * In [AppDelegate.m](https://github.com/ngzhongcai/lompang/blob/master/saas/AppDelegate.m) * Under didFinishLaunchingWithOptions, add the following lines * ```self.lompang= [[Lompang alloc] init];``` * ```self.lompang.delegate= self; ``` * ```[self.lompang connectToAccount:@"" WithToken:@""];``` * Add the following delegate methods * ```-(void)socketConnected:(NSDictionary *)dict;``` * ```-(void)socketDisconnected;``` * ```-(void)socketReceivedErr:(NSDictionary *)dict;``` * ```-(void)socketRegistered:(NSDictionary *)dict;``` * ```-(void)socketUnregistered;``` * ```-(void)socketReceivedDict:(NSDictionary *)dict;``` * Under socketConnected, register for APNS push notifications * ```[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert)];``` * Add the following APNS delegate method * ```-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;``` * Under didRegisterForRemoteNotificationsWithDeviceToken, add * ```[self.lompang registerApns:deviceToken];``` * Under socketRegistered, start making the calls out to Lompang SDK. * [Please refer here for a list of all supported methods.](https://github.com/ngzhongcai/lompang/blob/master/Lompang/Lompang.h)

About

Want a Uber-like on-demand app? Add pubsub messaging functionalities without having to worry about backend!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published