PubNub Real-time Network iOS Multi-user Dashboard GeoLocation App
This is a good question regarding creating an app that provides user location dots on a map. Basically user connects to a PubNub Channel using PubNub.subscribe()
and will receive any LAT/LONG coordinates from other users. All users issue PubNub.Publish(LAT/LONG)
code in order to a channel which is received by all users connected to that channel.
Splitting and Segmenting Populations via PubNub Data Channels
In order to segment the population you simply use different channels.
iOS Background Tasks Updated Location PubNub
You have several options to run background threads on iOS7. The recommended option is binding to the Background GeoLocation Change Event, then issuing a PubNub.Publish(LAT/LONG)
in order to send the change. You'll bind on for iOS Multitasking: Background Location http://mobile.tutsplus.com/tutorials/iphone/ios-multitasking-background-location/ for didUpdateToLocation
. The Background Location is extremely easy to implement.
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
// Increased Accuracy is used only when app is Visible/Open.
// Otherwise only significant changes are transmittable.
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
- (void)
locationManager: (CLLocationManager *)manager
didUpdateToLocation: (CLLocation *)newLocation
fromLocation: (CLLocation *)oldLocation {
CLLocationCoordinate2D currentCoordinates = newLocation.coordinate;
NSLog(
@" NEW LOCATION: Lat(%f) Long(%f)",
currentCoordinates.latitude,
currentCoordinates.longitude
);
// Define a channel
PNChannel *channel_1 = [PNChannel channelWithName:@"a" shouldObservePresence:NO];
// Send Lat/Long
[PubNub sendMessage:@{@"lat":currentCoordinates.latitude,@"long":currentCoordinates.longitude} toChannel:channel_1];
}
PubNub iOS Basics: https://github.com/pubnub/objective-c/tree/master/iOS#lets-start-coding-now-with-pubnub
Connection Pricing on PubNub
PubNub bills on Daily Active Devices metric. If the user was connected all day or at any point that day, then we increment a counter by 1
. This is in a 24 hour window where we increment this number. After 24 hours the value resets to 0
.
PubNub Presence
Presence on PubNub will provide you connection analytics on a Per-channel basis allowing you to detect total connected devices at the very moment, in real-time.