久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='BhiZ8'></bdo><ul id='BhiZ8'></ul>

    <small id='BhiZ8'></small><noframes id='BhiZ8'>

    <i id='BhiZ8'><tr id='BhiZ8'><dt id='BhiZ8'><q id='BhiZ8'><span id='BhiZ8'><b id='BhiZ8'><form id='BhiZ8'><ins id='BhiZ8'></ins><ul id='BhiZ8'></ul><sub id='BhiZ8'></sub></form><legend id='BhiZ8'></legend><bdo id='BhiZ8'><pre id='BhiZ8'><center id='BhiZ8'></center></pre></bdo></b><th id='BhiZ8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BhiZ8'><tfoot id='BhiZ8'></tfoot><dl id='BhiZ8'><fieldset id='BhiZ8'></fieldset></dl></div>
    1. <tfoot id='BhiZ8'></tfoot>

      <legend id='BhiZ8'><style id='BhiZ8'><dir id='BhiZ8'><q id='BhiZ8'></q></dir></style></legend>

      如何在 iOS 上使用基于地理的推送通知?

      How to use geo-based push notifications on iOS?(如何在 iOS 上使用基于地理的推送通知?)
        <bdo id='20wTo'></bdo><ul id='20wTo'></ul>
      • <i id='20wTo'><tr id='20wTo'><dt id='20wTo'><q id='20wTo'><span id='20wTo'><b id='20wTo'><form id='20wTo'><ins id='20wTo'></ins><ul id='20wTo'></ul><sub id='20wTo'></sub></form><legend id='20wTo'></legend><bdo id='20wTo'><pre id='20wTo'><center id='20wTo'></center></pre></bdo></b><th id='20wTo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='20wTo'><tfoot id='20wTo'></tfoot><dl id='20wTo'><fieldset id='20wTo'></fieldset></dl></div>

        1. <tfoot id='20wTo'></tfoot>

          <small id='20wTo'></small><noframes id='20wTo'>

            <legend id='20wTo'><style id='20wTo'><dir id='20wTo'><q id='20wTo'></q></dir></style></legend>

                <tbody id='20wTo'></tbody>
              • 本文介紹了如何在 iOS 上使用基于地理的推送通知?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                當應用程序被殺死(不是在后臺)時,是否可以在 iOS 上使用基于地理的推送通知?

                Is it possible to make use of geo-based push notifications on iOS when the application is killed (not in the background)?

                我有興趣構建一個應用程序,用戶將在其中選擇地圖上的位置,然后如果他/她靠近該區域,則會觸發基于本地地理的推送通知.

                I am interested in building an app, where the user will choose a position on a map, and then if he/she for example is close to that area a local geo-based push notification would be triggered.

                但是,這個想法"是否可能?GPS 是否可以在應用程序被殺死并運行并在到位時通知用戶時運行并比較坐標?是否有我可以閱讀的關于該主題的任何類型的教程/文章/更多信息?

                However is this "idea" even possible? Can the GPS run and compare coordinates when the app is killed and run and notify the user when is in place? Is there a tutorial/article/more information of any kind on the subject that i could read?

                我在網上閱讀的大部分信息更像是實施的一般想法,但沒有任何具體內容.

                Most of the information I read online were more like general ideas of implementing without anything specific though on the matter.

                推薦答案

                對于在應用未運行(即之前已終止)時跟蹤用戶的位置,有兩種選擇:

                For tracking a user's location while the app is not running (ie. has previously been terminated), there are two options:

                1. 來自 iOS 應用編程指南在跟蹤用戶位置"下:

                對于不需要高精度位置數據的應用,強烈建議使用重大變化的位置服務.使用此服務,僅當用戶的位置發生重大變化時才會生成位置更新;因此,它非常適合社交應用程序或為用戶提供非關鍵、位置相關信息的應用程序.如果應用程序在發生更新時被掛起,系統會在后臺將其喚醒以處理更新.如果應用啟動此服務然后終止,系統會在新位置可用時自動重新啟動應用.此服務在 iOS 4 及更高版本中可用,并且僅在包含蜂窩無線電的設備上可用.

                The significant-change location service is highly recommended for apps that do not need high-precision location data. With this service, location updates are generated only when the user’s location changes significantly; thus, it is ideal for social apps or apps that provide the user with noncritical, location-relevant information. If the app is suspended when an update occurs, the system wakes it up in the background to handle the update. If the app starts this service and is then terminated, the system relaunches the app automatically when a new location becomes available. This service is available in iOS 4 and later, and it is available only on devices that contain a cellular radio.

                但是,根據 CLLocationManager 類參考, 不太準確,更新也不頻繁:

                However, according to the CLLocationManager class reference, it's not too accurate and updates are infrequent:

                注意:只要設備從之前的通知移動 500 米或更遠,應用程序就會收到通知.它不應期望通知的頻率超過每五分鐘一次.如果設備能夠從網絡中檢索數據,則位置管理器更有可能及時發送通知.

                Note: Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.

              • 區域監控以類似的方式工作 - 包括在被終止后重新啟動應用程序 - 但精度更高(取決于 Wifi 網絡和手機信號塔的可用性):

              • Region Monitoring works in a similar way - including restarting the app after being terminated - but with higher accuracy (depending on availability of Wifi networks and cell towers):

                具體的閾值距離由硬件和當前可用的定位技術決定.例如,如果禁用 Wi-Fi,則區域監控的準確性會大大降低.但是,出于測試目的,您可以假設最短距離約為 200 米.

                The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.

                另一個區域監控考慮是(根據 CLLocationManager 類參考) 區域進出通知可能僅在跨越區域邊界后 3-5 分鐘左右收到.

                Another region monitoring consideration is that (according to the CLLocationManager class reference) region entry and exit notifications might only be received 3-5 minutes or so after crossing the region's boundaries.

                根據實際需求,可以使用區域監控來獲取粗略"位置,然后當用戶在特定區域內時,在位置管理器上啟動更準確的基于 GPS 的服務.當用戶離開感興趣的區域時,關閉GPS服務以節省電池并再次恢復到粗略的位置監控服務(即區域監控).這是一個基本的實現:

                Depending on the actual requirements, region monitoring could be used for obtaining a "rough" location and then when the user is within a specific region, start up the more accurate GPS based service on the location manager. When the user leaves the region of interest, turn off the GPS service to preserve battery and revert to the rough location monitoring service (ie. region monitoring) once again. Here's a basic implementation:

                SomeViewController.m:

                ...
                @interface SomeViewController () <CLLocationManagerDelegate>
                
                @property (nonatomic, strong) CLLocationManager *locationManager;
                @property (nonatomic, strong) CLRegion *someRegion;
                
                @end
                
                @implementation SomeViewController
                
                - (void)viewDidLoad
                {
                    [super viewDidLoad];
                
                    self.locationManager = [[CLLocationManager alloc] init];
                
                    CLLocationDistance radius = 10; // 10 metre sensitivity
                    self.someRegion = [[CLRegion alloc] initCircularRegionWithCenter:someCoordinates radius:radius identifier:@"Smithtown Dry Cleaners"];
                
                    self.locationManager.delegate = self;
                    [self.locationManager startMonitoringForRegion:self.someRegion];
                
                    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
                    self.locationManager.distanceFilter = 10;
                    [self.locationManager startUpdatingLocation];
                }
                
                - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
                {
                    [self.locationManager startUpdatingLocation];
                }
                
                - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
                {
                    [self.locationManager stopUpdatingLocation];
                }
                
                // Delegate method from the CLLocationManagerDelegate protocol.
                - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
                {
                    CLLocation* location = [locations lastObject];
                
                    // If the user's current location is not within the region anymore, stop updating
                    if ([self.someRegion containsCoordinate:location.coordinate] == NO) {
                        [self.locationManager stopUpdatingLocation];
                    }
                
                    NSString *locationData = [NSString stringWithFormat:@"latitude %+.6f, longitude %+.6f
                ",
                                              location.coordinate.latitude,
                                              location.coordinate.longitude];
                    NSLog(@"%@", locationData);
                
                    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
                    localNotification.alertBody = locationData;
                    localNotification.alertAction = @"Location data received";
                    localNotification.hasAction = YES;
                    [[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
                }
                

                記得將適當的條目添加到應用程序的 plist 文件中,以便應用程序在后臺運行并訪問適當的資源:

                Remember to add the appropriate entries to the application's plist file so the app will run in the background with access to the appropriate resources:

                MyApp-Info.plist:

                <key>UIBackgroundModes</key>
                <array>
                        ...
                        <string>location</string>
                </array>
                <key>UIRequiredDeviceCapabilities</key>
                <array>
                        ...
                        <string>location-services</string>
                        <string>gps</string>
                </array>
                

                以上代碼假設使用 iOS6 和 ARC

                這篇關于如何在 iOS 上使用基于地理的推送通知?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!
              • 相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                <i id='NZe2m'><tr id='NZe2m'><dt id='NZe2m'><q id='NZe2m'><span id='NZe2m'><b id='NZe2m'><form id='NZe2m'><ins id='NZe2m'></ins><ul id='NZe2m'></ul><sub id='NZe2m'></sub></form><legend id='NZe2m'></legend><bdo id='NZe2m'><pre id='NZe2m'><center id='NZe2m'></center></pre></bdo></b><th id='NZe2m'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NZe2m'><tfoot id='NZe2m'></tfoot><dl id='NZe2m'><fieldset id='NZe2m'></fieldset></dl></div>

                      <tbody id='NZe2m'></tbody>
                    <tfoot id='NZe2m'></tfoot>
                    <legend id='NZe2m'><style id='NZe2m'><dir id='NZe2m'><q id='NZe2m'></q></dir></style></legend>
                  1. <small id='NZe2m'></small><noframes id='NZe2m'>

                          <bdo id='NZe2m'></bdo><ul id='NZe2m'></ul>
                          主站蜘蛛池模板: 精品久久久久久久久久 | 情侣酒店偷拍一区二区在线播放 | 在线欧美一区二区 | 久草欧美视频 | 日韩免费视频一区二区 | 日韩欧美在线视频观看 | 999久久久免费精品国产 | 欧美日韩亚洲视频 | 国产一级大片 | 欧美日韩综合一区 | 国产精品久久久久一区二区三区 | 在线观看亚洲精品 | 91精品国产综合久久久久久首页 | 日日日视频 | 99精品福利视频 | 天天爽综合网 | 毛片大全 | 亚州毛片 | 欧美一区二区三区 | 精产国产伦理一二三区 | 日本三级做a全过程在线观看 | 国产乱码一二三区精品 | 91精品国产麻豆 | 无码一区二区三区视频 | 蜜桃免费av| 精品欧美一区二区久久久伦 | 久久69精品久久久久久久电影好 | 国产91精品久久久久久久网曝门 | 欧美色性| 99精品99久久久久久宅男 | 狠狠操在线 | 中文字幕不卡在线观看 | 午夜精品一区二区三区在线 | 日本精品视频一区二区 | 毛色毛片免费看 | 一区二区三区电影在线观看 | 亚洲高清视频在线观看 | 欧美成人免费在线视频 | 国产精品1区| 一起操网站 | 五月网婷婷 |