Salesforce Marketing Cloud SDK 集成指南
概览
此文档将展示如何在您的iOS应用中实现PointSDK
和MarketingCloudSDK
,并与BluedotPointSDK-Salesforce
框架结合使用。
入门
将类似于以下内容的模块添加到Podfile中:pod 'BluedotPointSDK-Salesforce', '~> 1.0'
target 'MyApp' do
pod 'BluedotPointSDK-Salesforce', '~> 1.0'
end
然后在您的终端中运行pod install
命令,或在CocoaPods.app中运行。
将MarketingCloudSDKConfiguration.json
添加到您的项目中,并按以下配置进行设置。
[{
"name": "production",
"appid": "__your app id__",
"accesstoken": "__your access token__",
"marketing_cloud_server_url": "__your app endpoint__",
"mid": "__your account mid__",
"etanalytics": false,
"pianalytics": false,
"location": false,
"inbox": false,
"uselegacypiidentifier": true
}]
将MarketingCloudSDKConfiguration.json添加到您的目标“构建阶段”设置中的“复制Bundle资源”。
将以下键添加到您的Info.plist中
<key>BDPointApiKey</key>
<string>your PointSDK API key</string>
将UNUserNotificationCenterDelegate
添加到AppDelegate中。按照以下所示实现。
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[MarketingCloudSDK sharedInstance] sfmc_setDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
os_log_debug(OS_LOG_DEFAULT, "didFailToRegisterForRemoteNotificationsWithError = %@", error);
}
// The method will be called on the delegate when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction. The delegate must be set before the application returns from applicationDidFinishLaunching:.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
// tell the MarketingCloudSDK about the notification
[[MarketingCloudSDK sharedInstance] sfmc_setNotificationRequest:response.notification.request];
if (completionHandler != nil) {
completionHandler();
}
}
// This method is REQUIRED for correct functionality of the SDK.
// This method will be called on the delegate when the application receives a silent push
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
UNMutableNotificationContent *theSilentPushContent = [[UNMutableNotificationContent alloc] init];
theSilentPushContent.userInfo = userInfo;
UNNotificationRequest *theSilentPushRequest = [UNNotificationRequest requestWithIdentifier:[NSUUID UUID].UUIDString content:theSilentPushContent trigger:nil];
[[MarketingCloudSDK sharedInstance] sfmc_setNotificationRequest:theSilentPushRequest];
completionHandler(UIBackgroundFetchResultNewData);
}
在您的应用程序中实现BDPZoneEventReporterDelegate
和BDPIntegrationManagerDelegate
。然后使用Bluedot点和Marketing Cloud平台进行身份验证。
[BDIntegrationManager.instance authenticateMarketingCloudSDK];
[BDIntegrationManager.instance authenticateBDPointWithAuthorization:authorizedAlways];
有关更多详细信息,请访问Bluedot 文档和MarketingCloudSDK iOS,并查看我们的集成示例
版权和许可
由Bluedot Innovation于2018年创建。版权©2018 Bluedot Innovation。保留所有权利。
通过下载或使用Bluedot Point SDK for iOS,您同意Bluedot的条款和条件、隐私政策和账单政策,并承认这些条款管理您对iOS SDK的使用和访问。