我需要将用 Objective-C 编写的旧应用程序迁移到 Swift。 此应用程序使用 IBM 解决方案 Silverpop 来推送通知。
我在使用 Silverpop 解决方案迁移期间遇到了一些问题。 该框架是用 Objective-C 编写的,当我按照 GitHub 上的文档或示例(文档和示例之间存在差异..)时,我无法使应用程序运行。
应用程序在文档要求我创建的 main.swift
中崩溃:
import Foundation
import UIKit
UIApplicationMain(CommandLine.argc, nil, nil, "MCEAppDelegate")
启动时应用程序崩溃:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x8)
样本:https://github.com/ibm-mobile-push/ios/tree/master/samples/Swift%20Automatic%20Sample/SwiftSample
我的 MceConfig.json
{
"baseUrl": "https://api.ibm.xtify.com/3.0/",
"appKey": {
"dev":"xxxx",
"prod":"xxxx"
},
"appDelegateClass": "AppDelegate",
"autoInitializeFlag": true,
"sessionTimeout": 20,
"metricTimeInterval": 180,
"loglevel": "verbose",
"logfile": false
}
任何帮助将不胜感激!
最佳答案
您的 MceConfig.json 未遵循示例代码中的文档和注释。
Setting up the sample app that is included in the Mobile App Messaging SDK for iOS.
- Swift requires your class to be in a namespace. For this reason, if you are using the Swift Sample App, update the “appDelegateClass” value to “SwiftSample.AppDelegate”.
MceConfig.json在示例代码中:
"Please note: if you are using a Swift based Application Delegate you must include the product name and class name in AppDelegateClass, for example": "SwiftSample.AppDelegate", "appDelegateClass": "AppDelegate",
尝试更改 MceConfig.json 中的行 来自:
"appDelegateClass": "AppDelegate",
致:
"appDelegateClass": "YourAppProductName.AppDelegate",
(将 YourAppProductName
替换为您应用的实际产品名称。)
关于ios - Swift 中的 IBM Silverpop 推送集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51331066/