Ruby on rails 使用PubNub实现多用户移动位置仪表板

Ruby on rails 使用PubNub实现多用户移动位置仪表板,ruby-on-rails,ios7,pubnub,Ruby On Rails,Ios7,Pubnub,我正在尝试创建一个示例IOS应用程序,它将移动设备的位置更新从后台发布到rails后端,rails后端连接到postgres数据库并显示web前端 工作流程: 基本上,当用户在其移动应用程序上通过ouath登录时,该应用程序进入后台,并继续使用pubnub频道向服务器发送后台位置数据。因此,用户X登录到其手机上的应用程序中,用户Y登录到其手机上的应用程序中,他们连接到一个频道,该频道将他们放在仪表板上。现在,一个用户M登录到仪表板,只找到用户X和Y。另一个用户Z可以登录他的手机,但他使用单独的频

我正在尝试创建一个示例IOS应用程序,它将移动设备的位置更新从后台发布到rails后端,rails后端连接到postgres数据库并显示web前端

工作流程:

基本上,当用户在其移动应用程序上通过ouath登录时,该应用程序进入后台,并继续使用pubnub频道向服务器发送后台位置数据。因此,用户X登录到其手机上的应用程序中,用户Y登录到其手机上的应用程序中,他们连接到一个频道,该频道将他们放在仪表板上。现在,一个用户M登录到仪表板,只找到用户X和Y。另一个用户Z可以登录他的手机,但他使用单独的频道(?),因此当M登录到web仪表板时不会显示,但当另一个用户N登录时会显示

所以

我的问题有三个方面:

1.)我是否必须为每个仪表板用户创建单独的通道来实现这一点,然后分别连接它们

2.)是否有后台pubnub支持从后台发送位置更新(IOS7允许)

3.)连接定价有点混乱,是否有人知道对于上面所示的实现,每个连接到任何通道或每个通道或其他方式的定价结构会是什么样的

我假设我必须启用pubnub presence enable才能做到这一点

有没有做类似事情的示例应用程序(可能聊天应用程序会喜欢这样的东西)?Pubnub有很多关于API的文档,但示例较少。

Pubnub实时网络iOS多用户仪表板地理位置应用程序 这是一个关于创建在地图上提供用户位置点的应用程序的好问题。基本上,用户使用
PubNub.subscribe()
连接到一个PubNub频道,并将从其他用户处接收任何LAT/LONG坐标。所有用户发布
PubNub.Publish(LAT/LONG)
代码,以便连接到该频道的所有用户都能接收到该频道

通过PubNub数据通道分割和分割种群 为了对人群进行细分,您只需使用不同的频道

iOS后台任务更新位置PubNub 您有几个选项可以在iOS7上运行后台线程。建议的选项是绑定到后台地理位置更改事件,然后发出
Publish.Publish(LAT/LONG)
以发送更改。您将绑定到iOS多任务:didUpdateToLocation的后台位置。背景位置非常容易实现

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基础:

PubNub上的连接定价 公共票据是公制的。如果用户整天或当天的任何时候都在连接,那么我们将计数器增加
1
。这是在一个24小时窗口中,我们增加这个数字。24小时后,该值重置为
0

公共存在
PubNub上的显示将为您提供基于每个通道的连接分析,允许您实时检测当前连接的设备总数。

查看此帖子,并将很快提供一些反馈。iOS->Rails RoR->Postgresql->PubNub->JavaScript Dashboard?基本上,iOS应用程序,PubNub for real time location comm,ROR/Postgres用于框架/存储位置数据,JS前端用于仪表板:)此外,请查看How-do-I-Use-Channels-In-my-Application-了解使用私有和公共通道的更详细用法。最后,如果你被困住了,请随时联系我们support@pubnub.com,我们很高兴能帮助您使用存根代码,让您顺利运行!这真是太棒了,谢谢@PubNub让我来讨论一下,如果有问题,请继续提问,并标记为答案。@PubNub我可以创建运行时频道吗?我是否必须在开始时指定要连接到哪个频道?还有,IOS应用程序(生产者)连接到接收数据的rails服务器(消费者)的示例代码吗?是!可以创建运行时通道,因为通道是动态的。要连接到Rails(RoR)运行时,您需要使用标准HTTP请求来访问Rails REST接口。您可以考虑REST工具包
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];
}