最后更新时间:2025-03-26


快速集成





一、 SDK集成

提供两种集成方式供iOS开发者选择:

  • 通过CocoaPods集成
  • 手动集成

1、通过CocoaPods集成

在工程的 Podfile 里面添加以下代码

pod 'TencentNavKit', '6.12.0'
pod 'libwebp'

TencentNavKit最新版本请参考:https://lbs.qq.com/mobile/ios_nav_sdk/download/naviSDK

2、手动集成

i. 将如下Framework以及资源Bundle加入Xcode工程中

ii. 在工程->Targets->Build Phases->Link Binary With Libraries中添加如下系统库 * CoreMotion.framework * libc++.tbd * libsqlite3.0.tbd

iii. 在Targets->Building Settings -> Other Linker Flags中添加 -ObjC

iv. 导航SDK依赖libwebp,请引入libwebp

二、工程配置

  1. 添加相关系统权限。在工程->Targets->Info中添加如下定位权限,
  • Privacy - Location Always Usage Description

  • Privacy - Location Always and When In Use Usage Description

  • Privacy - Location When In Use Usage Description

  1. 如果需要后台定位,需在IOS 9.0及以上版本并设allowBackgroundLocationUpdatesYES,此时必须保证TARGETS->Capabilities->Background Modes->Location updates处于选中状态

三、初始化

在工程的“AppDelegate.m”中引入QMapKit.hTencentNavKit.h,并配置开发者Key,此步骤为必须。

// 引入QMapKit.h和TencentNavKit.h
#import <QMapKit/QMapKit.h>  
#import<TencentNavKit/TencentNavKit.h>


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    // 地图SDK隐私合规接口,同意隐私合规
    [[QMapServices sharedServices] setPrivacyAgreement:YES];
    // 导航SDK隐私合规接口,同意隐私合规
    [[TNKNavServices sharedServices] setPrivacyAgreement:YES];

    //地图SDK的key配置
    [QMapServices sharedServices].APIKey = @"您的key";
    //导航SDK的key配置
    [TNKNavServices sharedServices].key = @"您的key";
	
    // 记录设备标识,反馈导航问题时请提供该设备标识以及发生问题的时间
    NSString *deviceID = [TNKNavServices sharedServices].identifier;

    return YES;
}
本页内容