3

Ich verwende GCM, um Apple Push-Benachrichtigung an meine iOS-App zu senden, Benachrichtigungen funktionieren gut, aber ohne Ton.
Wie kann ich dieses Problem beheben?
Dies ist mein Code unten:Kein Ton von Remote-Benachrichtigung in Swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
    // Override point for customization after application launch. 

    // Preloads keyboard so there's no lag on initial keyboard appearance. 
    let lagFreeField:UITextField = UITextField(); 

    self.window?.addSubview(lagFreeField); 
    lagFreeField.becomeFirstResponder(); 
    lagFreeField.resignFirstResponder(); 
    lagFreeField.removeFromSuperview(); 

    locationManager = CLLocationManager() 
    locationManager?.requestWhenInUseAuthorization() 

    var configureError:NSError? 
    GGLContext.sharedInstance().configureWithError(&configureError) 
    assert(configureError == nil, "Error configuring Google services: \(configureError)") 
    gcmSenderID = GGLContext.sharedInstance().configuration.gcmSenderID 

    if #available(iOS 8.0, *) { 
     let settings: UIUserNotificationSettings = 
      UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound.union(UIUserNotificationType.Alert), categories: nil) 
     application.registerUserNotificationSettings(settings) 
     application.registerForRemoteNotifications() 
    } else { 
     let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) 
     UIApplication.sharedApplication().registerUserNotificationSettings(settings) 
     UIApplication.sharedApplication().registerForRemoteNotifications() 
    } 
    let gcmConfig = GCMConfig.defaultConfig() 
    gcmConfig.receiverDelegate = self 
    GCMService.sharedInstance().startWithConfig(gcmConfig) 
    return true 
} 

Antwort

2

Das Problem ist, mit Google Cloud Messaging. Sie unterstützen nur den "Standard" -Wert für das Sound-Tag. Also, wann immer ich es zu etwas änderte, aber der GCM-Server sendet das Sound-Tag überhaupt nicht. cloud-messaging enter image description here