Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS正在接收多个推送通知_Ios_Swift_Parse Platform_Notifications_Urbanairship.com - Fatal编程技术网

iOS正在接收多个推送通知

iOS正在接收多个推送通知,ios,swift,parse-platform,notifications,urbanairship.com,Ios,Swift,Parse Platform,Notifications,Urbanairship.com,我正在开发一个已启用推送通知的应用程序。我的应用程序从第一天开始使用推送通知,服务器为parse.com 一切正常很好,我做了几次应用程序更新和改进,每次服务器发送推送都会收到一个通知,我也从parse 1.7.2更新到了1.12.0,没有任何问题 由于parse.com将终止其服务,我开始从parse迁移到城市飞艇(使用7.0.2) 我做了几次测试,在我的手机上安装和卸载应用程序,安装生产版本(使用parse)和安装开发版本(使用urban airship),一切正常,当突然我不知道为什么,我

我正在开发一个已启用推送通知的应用程序。我的应用程序从第一天开始使用推送通知,服务器为parse.com

一切正常很好,我做了几次应用程序更新和改进,每次服务器发送推送都会收到一个通知,我也从parse 1.7.2更新到了1.12.0,没有任何问题

由于parse.com将终止其服务,我开始从parse迁移到城市飞艇(使用7.0.2)

我做了几次测试,在我的手机上安装和卸载应用程序,安装生产版本(使用parse)和安装开发版本(使用urban airship),一切正常,当突然我不知道为什么,我开始接收服务器每次推送发送的5个通知。我认为这是parse.com的一个问题,因为当时我的iPhone正在运行生产版(带parse),但事实并非如此

当版本(使用城市飞艇)刚刚发布时,我一直收到5条通知

我完全迷失在这里,我不知道为什么会发生这种情况,起初我认为这和应用程序的多次安装和卸载有关,所以我尝试:

1. Disabling notifications.-
2. Deleting the app.-
3. Disabling notifications
3.a. deleting the app
3.b. then changing time and date ahead a couple of days
3.c. then turning off the phone
3.d. turning on again and putting the right date
3.e. restarting the phone
3.f. installing the app
到目前为止,这些措施都没有奏效。我在网上找不到关于这个问题的任何明确的或解决这个问题的东西

我希望有人能帮助我

额外信息:

Swift 2
iOS 8.0+
XCode 7
Pushes are sent by a PHP Server
我的AppDelegate.swift(请注意,我只包含了相关代码,其余代码不相关):


我希望有人能帮助我,当我在我的开发环境上进行测试时,一切都很好,现在它失败的原因完全是个谜。

你提到了一个pho服务器,那就是与城市飞艇对话?您是否在该服务器上多次注册,而不是替换新Id,而是将其添加为新Id?PHP服务器只是在这些通道上推送。例如:如果事件1发生发送到标记notType1,如果事件2发生发送到标记notType2,如果事件1和2发生,发送到notType1和notType2。如果我查看通知报告,它显示只需一次推送。我没有发现任何奇怪的地方。好吧,这似乎是一个多注册的问题,这就是为什么我问染料,但问题是在哪里或为什么:/我唯一要做的是使用addTag、removeTag更新设置部分中的标记,然后使用updateRegistration()更新你看过parse中的安装和UA中的重复通道了吗?
import UIKit
import CoreData
import AirshipKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let config: UAConfig = UAConfig.defaultConfig()
        UAirship.takeOff(config)
        UAirship.push().userPushNotificationsEnabled = true
        UAirship.push().resetBadge()

        // Get the user settings
        let userSettings = NSUserDefaults.standardUserDefaults()
        var notify = userSettings.dictionaryForKey("notifications")
        let appReset = userSettings.objectForKey("appResetv200")

        if appReset == nil {
            notify = nil

            userSettings.setObject("done", forKey: "appResetv200")
        }

        if notify == nil {
            let notificationTypes = [
                "notType1" : true,
                "notType2" : true,
                "notType3" : true
            ]

            userSettings.setObject(notificationTypes, forKey: "notifications")

            UAirship.push().addTag("notType1")
            UAirship.push().addTag("notType2")
            UAirship.push().addTag("notType3")
            UAirship.push().updateRegistration()
        }

        return true
    }
}