iOS के लिए Driver SDK टूल का इस्तेमाल शुरू करना

ड्राइवर SDK टूल ऐसी लाइब्रेरी है जिसे ड्राइवर ऐप्लिकेशन के साथ इंटिग्रेट किया जाता है. इसकी मदद से, फ़्लीट इंजन को ड्राइवर की जगह, रास्ता, बची हुई दूरी, और ETA के साथ अपडेट किया जाता है. यह नेविगेशन SDK टूल के साथ भी काम करता है. इससे ड्राइवर को मोड़-दर-मोड़ नेविगेट करने के निर्देश मिलते हैं.

सिस्टम में कम से कम यह कॉन्फ़िगरेशन होना चाहिए

  • मोबाइल डिवाइस में iOS 14 या उसके बाद का वर्शन होना चाहिए.
  • Xcode का 15 या इसके बाद का वर्शन है.
  • ज़रूरी शर्तें

    इस गाइड में यह माना गया है कि आपके ऐप्लिकेशन में नेविगेशन SDK टूल पहले से लागू है और Fleet Engine बैकएंड सेट अप किया गया है और उपलब्ध है. हालांकि, इस कोड में नेविगेशन SDK टूल सेट अप करने के तरीके का सैंपल दिया गया है.

    आपको अपने Google Cloud प्रोजेक्ट में iOS के लिए Maps SDK टूल को भी चालू करना होगा और एपीआई पासकोड पाएं.

    ऐक्सेस पाएं

    अगर आप Google Workspace के ग्राहक हैं, तो ऑनबोर्डिंग के दौरान google-maps-platform-sdk-users@workspacedomain.com जैसा Workspace ग्रुप बनाएं और Google को उसका नाम बताएं. यह सुझाया गया तरीका है. इसके बाद, आपका Workspace ग्रुप, उन लोगों या संगठनों की सूची में शामिल कर दिया जाएगा जिनके पास CocoaPods के सही डेटा स्टोर करने की जगहों का ऐक्सेस होगा. पुष्टि करें कि उपयोगकर्ता के ईमेल और सेवा खाते के जिन ईमेल को ऐक्सेस चाहिए उन्हें इस सूची में शामिल किया गया है.

    अगर आपके संगठन के पास Workspace ग्रुप बनाने की सुविधा नहीं है, तो Google को उपयोगकर्ता और सेवा खाते से जुड़े ऐसे ईमेल की सूची भेजें जिनके लिए इन आर्टफ़ैक्ट का ऐक्सेस ज़रूरी है.

    लोकल डेवलपमेंट

    लोकल डेवलपमेंट के लिए, सिर्फ़ Cloud SDK टूल से लॉग इन करना काफ़ी है.

    gcloud

    gcloud auth login
    

    लॉग इन करने के लिए इस्तेमाल किया जाने वाला ईमेल पता, Workspace ग्रुप का सदस्य होना चाहिए.

    ऑटोमेशन (सिस्टम बनाना या लगातार इंटिग्रेशन करना)

    अपने ऑटोमेशन होस्ट को सबसे सही तरीकों के हिसाब से सेट अप करें:

    • अगर आपकी प्रोसेस Google Cloud के प्लैटफ़ॉर्म पर चलती है, तो ऑटोमैटिक क्रेडेंशियल की पहचान करने की सुविधा का इस्तेमाल करें.

    • इसके अलावा, सेवा खाते की कुंजी की फ़ाइल को होस्ट के फ़ाइल सिस्टम पर किसी सुरक्षित जगह पर सेव करें और GOOGLE_APPLICATION_CREDENTIALS के एनवायरमेंट वैरिएबल को सही तरीके से सेट करें.

    क्रेडेंशियल से जुड़े सेवा खाते का ईमेल पता, Workspace Goup का सदस्य होना चाहिए.

    प्रोजेक्ट कॉन्फ़िगरेशन

    CocoaPods का इस्तेमाल करके ड्राइवर SDK टूल को कॉन्फ़िगर किया जा सकता है.

    CocoaPods का इस्तेमाल करें

    CocoaPods का इस्तेमाल करके ड्राइवर SDK टूल को कॉन्फ़िगर करने के लिए, आपको इन आइटम की ज़रूरत होगी:

    1. ड्राइवर SDK टूल के लिए Podfile बनाएं और एपीआई और उसकी डिपेंडेंसी इंस्टॉल करने के लिए इसका इस्तेमाल करें: अपनी प्रोजेक्ट डायरेक्ट्री में Podfile नाम की फ़ाइल बनाएं. यह फ़ाइल आपके प्रोजेक्ट की डिपेंडेंसी के बारे में बताती है. Podfile में बदलाव करें और अपनी डिपेंडेंसी जोड़ें. यहां पर डिपेंडेंसी का एक उदाहरण दिया गया है:

      source "https://github.com/CocoaPods/Specs.git"
      
      target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
        pod 'GoogleRidesharingDriver'
      end
      
    2. Podfile को सेव करें. कोई टर्मिनल खोलें और Podfile वाली डायरेक्ट्री पर जाएं:

      cd <path-to-project>
      
    3. पॉड इंस्टॉल करने का निर्देश चलाएं. इससे, Podfile में बताए गए एपीआई और उनकी डिपेंडेंसी इंस्टॉल हो जाएंगी.

      pod install
      
    4. Xcode को बंद करें और Xcode लॉन्च करने के लिए, अपने प्रोजेक्ट की .xcworkspace फ़ाइल को खोलें. अब से, आपको प्रोजेक्ट खोलने के लिए .xcworkspace फ़ाइल का इस्तेमाल करना होगा.

    SDK टूल के ऐल्फ़ा/बीटा वर्शन

    iOS के लिए ड्राइवर SDK टूल के अल्फ़ा या बीटा वर्शन कॉन्फ़िगर करने के लिए आपको इन आइटम की ज़रूरत होगी:

    • CocoaPods टूल: इस टूल को इंस्टॉल करने के लिए, Terminal खोलें और नीचे दिया गया कमांड चलाएं.

      sudo gem install cocoapods
      

      ज़्यादा जानकारी के लिए, CocoaPods को इस्तेमाल करने के शुरुआती निर्देश देखें.

    • Google ऐक्सेस सूची में आपका डेवलपमेंट खाता. SDK टूल के ऐल्फ़ा और बीटा वर्शन का पॉड डेटा स्टोर करने की जगह, सार्वजनिक सोर्स नहीं है. उन वर्शन को ऐक्सेस करने के लिए, Google के ग्राहक इंजीनियर से संपर्क करें. इंजीनियर आपके डेवलपमेंट खाते को ऐक्सेस सूची में जोड़ता है. इसके बाद, पुष्टि के लिए कुकी सेट करता है.

    ऐक्सेस लिस्ट में अपने प्रोजेक्ट के शामिल होने के बाद, पॉड को ऐक्सेस किया जा सकता है.

    1. iOS के लिए ड्राइवर SDK टूल के लिए Podfile बनाएं और एपीआई और उसकी डिपेंडेंसी इंस्टॉल करने के लिए इसका इस्तेमाल करें: अपने प्रोजेक्ट डायरेक्ट्री में Podfile नाम की फ़ाइल बनाएं. यह फ़ाइल आपके प्रोजेक्ट की डिपेंडेंसी के बारे में बताती है. Podfile में बदलाव करें और अपनी डिपेंडेंसी जोड़ें. यहां पर डिपेंडेंसी का एक उदाहरण दिया गया है:

      source "https://cpdc-eap.googlesource.com/ridesharing-driver-sdk.git"
      source "https://github.com/CocoaPods/Specs.git"
      
      target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
        pod 'GoogleRidesharingDriver'
      end
      
    2. Podfile को सेव करें. कोई टर्मिनल खोलें और Podfile वाली डायरेक्ट्री पर जाएं:

      cd <path-to-project>
      
    3. पॉड इंस्टॉल करने का निर्देश चलाएं. इससे, Podfile में बताए गए एपीआई और उनकी डिपेंडेंसी इंस्टॉल हो जाएंगी.

      pod install
      
    4. Xcode को बंद करें और Xcode लॉन्च करने के लिए, अपने प्रोजेक्ट की .xcworkspace फ़ाइल को खोलें. अब से, आपको प्रोजेक्ट खोलने के लिए .xcworkspace फ़ाइल का इस्तेमाल करना होगा.

    XCFramework इंस्टॉल करना

    XCFramework एक बाइनरी पैकेज होता है, जिसका इस्तेमाल ड्राइवर SDK टूल को इंस्टॉल करने के लिए किया जाता है. इस पैकेज का इस्तेमाल कई प्लैटफ़ॉर्म पर किया जा सकता है. इनमें M1 चिपसेट का इस्तेमाल करने वाली मशीनें भी शामिल हैं. इस गाइड में, ड्राइवर SDK टूल वाले XCFramework को मैन्युअल तरीके से अपने प्रोजेक्ट में जोड़ने और Xcode में बिल्ड सेटिंग कॉन्फ़िगर करने का तरीका बताया गया है.

    SDK टूल बाइनरी और संसाधन डाउनलोड करें:

    1. XCFramework और संसाधनों को ऐक्सेस करने के लिए, ज़िप की गई फ़ाइलों को अनपैक करें.

    2. Xcode शुरू करें और या तो कोई मौजूदा प्रोजेक्ट खोलें या एक नया प्रोजेक्ट बनाएं. अगर आपने iOS का इस्तेमाल पहले कभी नहीं किया है, तो नया प्रोजेक्ट बनाएं और iOS ऐप्लिकेशन टेंप्लेट चुनें.

    3. अगर आपके प्रोजेक्ट ग्रुप में फ़्रेमवर्क पहले से मौजूद नहीं है, तो एक ग्रुप बनाएं.

    4. डाउनलोड की गई gRPCCertificates.bundle फ़ाइल को खींचकर, अपने Xcode प्रोजेक्ट की टॉप लेवल डायरेक्ट्री में छोड़ें. जब कहा जाए, तब 'आइटम कॉपी करें' को चुनें.

    5. ड्राइवर SDK टूल इंस्टॉल करने के लिए, GoogleRidesharingDriver.xcframework फ़ाइल को फ़्रेमवर्क, लाइब्रेरी, और एम्बेड किए गए कॉन्टेंट में जाकर अपने प्रोजेक्ट में खींचें और छोड़ें. जब कहा जाए, तब 'आइटम कॉपी करें' को चुनें.

    6. डाउनलोड किए गए GoogleRidesharingDriver.bundle को अपने Xcode प्रोजेक्ट की टॉप लेवल डायरेक्ट्री में खींचें और छोड़ें. जब कहा जाए, तब Copy items if needed चुनें.

    7. प्रोजेक्ट नेविगेटर से अपना प्रोजेक्ट चुनें और अपने ऐप्लिकेशन का टारगेट चुनें.

    8. बिल्ड के चरण टैब खोलें और अगर ये फ़्रेमवर्क और लाइब्रेरी पहले से मौजूद नहीं हैं, तो उन्हें लाइब्रेरी के साथ लिंक बाइनरी को जोड़ें:

      • Accelerate.framework
      • AudioToolbox.framework
      • AVFoundation.framework
      • CoreData.framework
      • CoreGraphics.framework
      • CoreLocation.framework
      • CoreTelephony.framework
      • CoreText.framework
      • GLKit.framework
      • ImageIO.framework
      • libc++.tbd
      • libxml2.tbd
      • libz.tbd
      • LocalAuthentication.framework
      • OpenGLES.framework
      • QuartzCore.framework
      • SystemConfiguration.framework
      • UIKit.framework
      • WebKit.framework
    9. किसी खास टारगेट के बजाय, अपना प्रोजेक्ट चुनें और बिल्ड सेटिंग टैब खोलें. अन्य लिंकर फ़्लैग सेक्शन में, डीबग और रिलीज़, दोनों के लिए ‑ObjC जोड़ें. अगर ये सेटिंग नहीं दिख रही हैं, तो बिल्ड सेटिंग बार में फ़िल्टर को बुनियादी से सभी में बदलें.

    अनुमति देने और पुष्टि करने की प्रोसेस लागू करें

    जब आपका ड्राइवर ऐप्लिकेशन, फ़्लीट इंजन बैकएंड को जनरेट करके अपडेट भेजता है, तो अनुरोधों में मान्य ऐक्सेस टोकन शामिल होने चाहिए. इन अनुरोधों को अनुमति देने और उनकी पुष्टि करने के लिए, ड्राइवर SDK टूल आपके ऑब्जेक्ट को GMTDAuthorization प्रोटोकॉल के मुताबिक कॉल करता है. ऑब्जेक्ट, ज़रूरी ऐक्सेस टोकन देने के लिए ज़िम्मेदार है.

    ऐप्लिकेशन डेवलपर के तौर पर, आपको यह चुनना होता है कि टोकन कैसे जनरेट किए जाएं. लागू करने पर ये काम किए जा सकते हैं:

    • किसी एचटीटीपीएस सर्वर से ऐक्सेस टोकन फ़ेच करें. हो सकता है कि यह JSON फ़ॉर्मैट में हो.
    • टोकन को पार्स और कैश मेमोरी में सेव करें.
    • टोकन की समयसीमा खत्म होने पर उसे रीफ़्रेश करें.

    अगर आपको फ़्लीट इंजन सर्वर से मिले टोकन के बारे में जानकारी चाहिए, तो अनुमति पाने के लिए JSON वेब टोकन (JWT) बनाना लेख पढ़ें.

    प्रोवाइडर आईडी और Google Cloud प्रोजेक्ट आईडी एक ही होते हैं. ज़्यादा जानकारी के लिए, Fleet Engine Distributionies API की उपयोगकर्ता गाइड देखें.

    यहां दिए गए उदाहरण में, ऐक्सेस टोकन देने वाली कंपनी के बारे में बताया गया है:

    #import "SampleAccessTokenProvider.h"
    #import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
    
    // SampleAccessTokenProvider.h
    @interface SampleAccessTokenProvider : NSObject<GMTDAuthorization>
    @end
    
    static NSString *const PROVIDER_URL = @"INSERT_YOUR_TOKEN_PROVIDER_URL";
    
    // SampleAccessTokenProvider.m
    @implementation SampleAccessTokenProvider{
      // The cached vehicle token.
      NSString *_cachedVehicleToken;
      // Keep track of the vehicle ID the cached token is for.
      NSString *_lastKnownVehicleID;
      // Keep track of when tokens expire for caching.
      NSTimeInterval _tokenExpiration;
    }
    
    - (void)fetchTokenWithContext:(nullable GMTDAuthorizationContext *)authorizationContext
                       completion:(nonnull GMTDAuthTokenFetchCompletionHandler)completion {
      if (!completion) {
        NSAssert(NO, @"%s encountered an unexpected nil completion.", __PRETTY_FUNCTION__);
        return;
      }
    
      // Get the vehicle ID from the authorizationContext. This is set by the Driver SDK.
      NSString *vehicleID = authorizationContext.vehicleID;
      if (!vehicleID) {
        NSAssert(NO, @"Vehicle ID is missing from authorizationContext.");
        return;
      }
    
    // Clear cached vehicle token if vehicle ID has changed.
      if (![_lastKnownVehicleID isEqual:vehicleID]) {
        _tokenExpiration = 0.0;
        _cachedVehicleToken = nil;
      }
      _lastKnownVehicleID = vehicleID;
    
      // Clear cached vehicle token if it has expired.
      if ([[NSDate date] timeIntervalSince1970] > _tokenExpiration) {
        _cachedVehicleToken = nil;
      }
    
      // If appropriate, use the cached token.
      if (_cachedVehicleToken) {
        completion(_cachedVehicleToken, nil);
        return;
      }
      // Otherwise, try to fetch a new token from your server.
      NSURL *requestURL = [NSURL URLWithString:PROVIDER_URL];
      NSMutableURLRequest *request = 
                              [[NSMutableURLRequest alloc] initWithURL:requestURL];
      request.HTTPMethod = @"GET";
      // Replace the following key values with the appropriate keys based on your
      // server's expected response.
      NSString *vehicleTokenKey = @"VEHICLE_TOKEN_KEY";
      NSString *tokenExpirationKey = @"TOKEN_EXPIRATION";
      __weak typeof(self) weakSelf = self;
      void (^handler)(NSData *_Nullable data, NSURLResponse *_Nullable response,
                      NSError *_Nullable error) =
          ^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {
            typeof(self) strongSelf = weakSelf;
            if (error) {
              completion(nil, error);
              return;
            }
    
            NSError *JSONError;
            NSMutableDictionary *JSONResponse =
                [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&JSONError];
    
            if (JSONError) {
              completion(nil, JSONError);
              return;
            } else {
              // Sample code only. No validation logic.
              id expirationData = JSONResponse[tokenExpirationKey];
              if ([expirationData isKindOfClass:[NSNumber class]]) {
                NSTimeInterval expirationTime = ((NSNumber *)expirationData).doubleValue;
                strongSelf->_tokenExpiration = [[NSDate date] timeIntervalSince1970] + expirationTime;
              }
              strongSelf->_cachedVehicleToken = JSONResponse[vehicleTokenKey];
              completion(JSONResponse[vehicleTokenKey], nil);
            }
        };
    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    NSURLSession *mainQueueURLSession =  
           [NSURLSession  sessionWithConfiguration:config delegate:nil
    delegateQueue:[NSOperationQueue mainQueue]];
    NSURLSessionDataTask *task = [mainQueueURLSession dataTaskWithRequest:request completionHandler:handler];
    [task resume];
    }
    
    @end
    

    DeliveryDriverAPI इंस्टेंस बनाएं

    GMTDDeliveryVehicleReporter इंस्टेंस पाने के लिए, आपको पहले providerID,vehicleID, driveContext और accessTokenProvider का इस्तेमाल करके GMTDDeliveryDriverAPI इंस्टेंस बनाना होगा. providerID और Google Cloud प्रोजेक्ट आईडी एक ही होते हैं. साथ ही, GMTDDeliveryVehicleReporter इंस्टेंस को सीधे ड्राइवर एपीआई से ऐक्सेस किया जा सकता है.

    नीचे दिए गए उदाहरण में, GMTDDeliveryDriverAPI इंस्टेंस बनाया गया है:

    #import “SampleViewController.h”
    #import “SampleAccessTokenProvider.h”
    #import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
    
    static NSString *const PROVIDER_ID = @"INSERT_YOUR_PROVIDER_ID";
    
    @implementation SampleViewController {
     GMSMapView *_mapView;
    }
    
    - (void)viewDidLoad {
      NSString *vehicleID = @"INSERT_CREATED_VEHICLE_ID";
      SampleAccessTokenProvider *accessTokenProvider = 
                                    [[SampleAccessTokenProvider alloc] init];
      GMTDDriverContext *driverContext = 
         [[GMTDDriverContext alloc] initWithAccessTokenProvider:accessTokenProvider
                                                     providerID:PROVIDER_ID 
                                                  vehicleID:vehicleID 
          navigator:_mapView.navigator];
    
      GMTDDeliveryDriverAPI *deliveryDriverAPI = [[GMTDDeliveryDriverAPI alloc] initWithDriverContext:driverContext];
    }
    

    वाहन के बारे में जानकारी देने वाली सुविधा के इवेंट भी सुनें

    locationTrackingEnabled के 'हां' पर सेट होने पर, GMTDDeliveryVehicleReporter समय-समय पर वाहन को अपडेट करता रहता है. समय-समय पर होने वाले इन अपडेट का जवाब देने के लिए, कोई भी ऑब्जेक्ट GMTDVehicleReporterListener प्रोटोकॉल का पालन करके, GMTDDeliveryVehicleReporter इवेंट की सदस्यता ले सकता है.

    आपके पास इन इवेंट को मैनेज करने का विकल्प होता है:

    • vehicleReporter:didSucceedVehicleUpdate

      इससे ड्राइवर ऐप्लिकेशन को सूचना मिलती है कि बैकएंड सेवाओं को गाड़ी की जगह और स्थिति से जुड़े अपडेट मिल गए हैं.

    • vehicleReporter:didFailVehicleUpdate:withError

      लिसनर को सूचना दी जाती है कि गाड़ी को अपडेट नहीं किया जा सका. जब तक जगह की जानकारी ट्रैक करने की सुविधा चालू है, तब तक GMTDDeliveryVehicleReporter, Fleet Engine बैकएंड को नया डेटा भेजता रहेगा.

    नीचे दिए गए उदाहरण में, इन इवेंट को हैंडल किया गया है:

    SampleViewController.h
    @interface SampleViewController : UIViewController<GMTDVehicleReporterListener>
    @end
    
    SampleViewController.m
    #import “SampleViewController.h”
    #import “SampleAccessTokenProvider.h”
    #import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
    
    static NSString *const PROVIDER_ID = @"INSERT_YOUR_PROVIDER_ID";
    
    @implementation SampleViewController {
     GMSMapView *_mapView;
    }
    
    
    - (void)viewDidLoad {
      // ASSUMES YOU IMPLEMENTED HAVE THE SAMPLE CODE UP TO THIS STEP.
      [ridesharingDriverAPI.vehicleReporter addListener:self];
    }
    
    - (void)vehicleReporter:(GMTDDeliveryVehicleReporter *)vehicleReporter didSucceedVehicleUpdate:(GMTDVehicleUpdate *)vehicleUpdate {
      // Handle update succeeded.
    }
    
    - (void)vehicleReporter:(GMTDDeliveryVehicleReporter *)vehicleReporter didFailVehicleUpdate:(GMTDVehicleUpdate *)vehicleUpdate withError:(NSError *)error {
      // Handle update failed.
    }
    
    @end
    

    जगह की जानकारी ट्रैक करने की सुविधा चालू करें

    जगह की जानकारी ट्रैक करने की सुविधा चालू करने के लिए, आपका ऐप्लिकेशन GMTDDeliveryVehicleReporter पर locationTrackingEnabled को YES पर सेट कर सकता है. फिर GMTDDeliveryVehicleReporter, जगह की जानकारी के अपडेट अपने-आप भेजेगा. जब GMSNavigator नेविगेशन मोड में होता है (जब डेस्टिनेशन setDestinations के ज़रिए सेट हो) और locationTrackingEnabled YES पर सेट हो, तो GMTDDeliveryVehicleReporter रास्ते और ETA के अपडेट भी अपने-आप भेजेगा.

    इन अपडेट के दौरान सेट किया गया रास्ता वही होगा जिस पर ड्राइवर नेविगेशन सेशन के दौरान नेविगेट कर रहा था. शिपमेंट ट्रैकिंग सही तरीके से काम करे, इसके लिए -setDestinations:callback: से सेट किया गया वेपॉइंट, फ़्लीट इंजन के बैकएंड में सेट किए गए डेस्टिनेशन से मेल खाना चाहिए.

    यहां दिए गए उदाहरण में, जगह की जानकारी ट्रैक करने की सुविधा चालू की गई है:

    SampleViewController.m
    #import “SampleViewController.h”
    #import “SampleAccessTokenProvider.h”
    #import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
    
    static NSString *const PROVIDER_ID = @"INSERT_YOUR_PROVIDER_ID";
    
    @implementation SampleViewController {
     GMSMapView *_mapView; 
    }
    
    - (void)viewDidLoad {
      // ASSUMES YOU IMPLEMENTED HAVE THE SAMPLE CODE UP TO THIS STEP.
      deliveryDriverAPI.vehicleReporter.locationTrackingEnabled = YES;
    }
    
    @end
    

    डिफ़ॉल्ट रूप से, रिपोर्टिंग इंटरवल 10 सेकंड का होता है, लेकिन रिपोर्टिंग इंटरवल को locationUpdateInterval की मदद से बदला जा सकता है. अपडेट के लिए कम से कम पांच सेकंड का इंटरवल इस्तेमाल किया जा सकता है. अपडेट के लिए ज़्यादा से ज़्यादा 60 सेकंड का इंटरवल इस्तेमाल किया जा सकता है. ज़्यादा बार अपडेट होने की वजह से, अनुरोध मिलने में ज़्यादा समय लग सकता है और गड़बड़ियां हो सकती हैं.

    जगह की जानकारी के अपडेट बंद करें

    आपका ऐप्लिकेशन, वाहन की जगह की जानकारी अपडेट करने की सुविधा बंद कर सकता है. उदाहरण के लिए, जब ड्राइवर की शिफ़्ट खत्म होती है, तब आपका ऐप्लिकेशन locationTrackingEnabled को NO पर सेट कर सकता है.

      _vehicleReporter.locationTrackingEnabled = NO
    

    अपडेट_मास्क से जुड़ी गड़बड़ियां ठीक करना

    जब GMTDDeliveryVehicleReporter वाहन का अपडेट भेजता है, तो मास्क खाली होने पर update_mask गड़बड़ी हो सकती है. आम तौर पर, यह गड़बड़ी, ब्राउज़र शुरू होने के बाद पहली बार अपडेट करते समय होती है. नीचे दिए गए उदाहरण में, इस गड़बड़ी को ठीक करने का तरीका बताया गया है:

    Swift

    import GoogleRidesharingDriver
    
    class VehicleReporterListener: NSObject, GMTDVehicleReporterListener {
      func vehicleReporter(
        _ vehicleReporter: GMTDVehicleReporter,
        didFail vehicleUpdate: GMTDVehicleUpdate,
        withError error: Error
      ) {
        let fullError = error as NSError
        if let innerError = fullError.userInfo[NSUnderlyingErrorKey] as? NSError {
          let innerFullError = innerError as NSError
          if innerFullError.localizedDescription.contains("update_mask cannot be empty") {
            emptyMaskUpdates += 1
            return
          }
        }
        failedUpdates += 1
      }
    
      override init() {
        emptyMaskUpdates = 0
        failedUpdates = 0
      }
    }
    
    

    Objective-C

    #import "VehicleReporterListener.h"
    #import <GoogleRidesharingDriver/GoogleRidesharingDriver.h>
    
    @implementation VehicleReporterListener {
      NSInteger emptyMaskUpdates = 0;
      NSInteger failedUpdates = 0;
    }
    
    - (void)vehicleReporter:(GMTDVehicleReporter *)vehicleReporter
      didFailVehicleUpdate:(GMTDVehicleUpdate *)vehicleUpdate
                 withError:(NSError *)error {
      for (NSError *underlyingError in error.underlyingErrors) {
        if ([underlyingError.localizedDescription containsString:@"update_mask cannot be empty"]) {
          emptyMaskUpdates += 1;
          return;
        }
      }
      failedUpdates += 1
    }
    
    @end