ios - Swift 中的 IBM Silverpop 推送集成

标签 ios objective-c swift push-notification

我需要将用 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://developer.ibm.com/customer-engagement/tutorials/getting-started-mobile-app-messaging-ios-apps/

样本: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.

  1. 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/

相关文章:

ios - Kiwi:有没有办法让示例的动态数量由运行时变量定义?

objective-c - iOS:在后台加载声音时出现多线程问题

ios - 如何在每个另一个 UILabel 位置下设置几个 UILabel 位置?

ios - Decode .utf8 可能无法在 swift 中正常运行吗?

ios - 当对象 A 将对象 B 作为属性并且对象 B 有包含对象 A 的数组属性时,Swift 中的保留循环?

ios - 同时应用过滤器和排序 firebase

ios - 如何从 HTML 响应中获取 IPv4 NSString?

ios - 将顶部边框添加到选定的 TabBar

objective-c - Objective C 中的 unavailable 属性是什么意思?

ios - 如何添加动画来切换 View ?