我已经能够设置Interactive LOCAL通知,但远程通知不起作用.我正在使用Parse.com发送JSON
我的AppDelegate.Swift看起来像这样:
//
// AppDelegate.swift
// SwifferApp
//
// Created by Training on 29/06/14.
// Copyright (c) 2014 Training. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
UINavigationBar.appearance().barTintColor = UIColor.orangeColor()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
Parse.setApplicationId("eUEC7O4Jad0Kt3orqRouU0OJhkGuE20n4uSfrLYE", clientKey: "WypmaQ8XyqH26AeWIANttqwUjRJR4CIM55ioXvez")
let notificationTypes:UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
return true
}
func application(application: UIApplication!, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings!) {
UIApplication.sharedApplication().registerForRemoteNotifications() …Run Code Online (Sandbox Code Playgroud) apple-push-notifications parse-platform appdelegate swift ios8
我想更新Swift 3的以下方法的命名:
public func imageWithUrl(url: String, placeholderNamed: String) {
if let image = UIImage(named: placeholderNamed) {
imageWithUrl(url: url, placeholder: image)
} else {
imageWithUrl(url: url)
}
}
Run Code Online (Sandbox Code Playgroud)
至
public func image(url: String, placeholderNamed: String) {
Run Code Online (Sandbox Code Playgroud)
所以我用这个方法弃用旧方法:
@available(*, deprecated: 1.8, renamed: "image(url:, placeholder:")
Run Code Online (Sandbox Code Playgroud)
问题是我收到以下错误:
'available'属性的'renamed'参数必须是运算符,标识符或完整函数名称,可选地由类型名称预设
我没有找到任何关于CLVisit的内容,所以我试图自己探索这项技术.
有谁知道它为什么不起作用?所有.plist键都已设置并正常工作.
class ViewController: UIViewController,CLLocationManagerDelegate {
var manager:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
manager = CLLocationManager()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestAlwaysAuthorization()
manager.startMonitoringVisits()
}
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
}
func locationManager(manager: CLLocationManager!,
didVisit visit: CLVisit!)
{
println("visit: \(visit.coordinate.latitude),\(visit.coordinate.longitude)")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud) 昨天我参加了一个watchkit黑客马拉松,我在使用Google Maps API并发送本地通知的NSObject类上调用方法时遇到了一些问题.如果我从我的Watchkit扩展中调用此方法,则代码无法编译,但是如果我从ViewController调用,例如,一切都运行正常
#import "InterfaceController.h"
#import "Methods.h"
@interface InterfaceController()
@end
@implementation InterfaceController
- (instancetype)initWithContext:(id)context {
self = [super initWithContext:context];
if (self){
// Initialize variables here.
// Configure interface objects here.
NSLog(@"%@ initWithContext", self);
}
return self;
}
- (IBAction)butRoute
{
Methods *mt = [[Methods alloc]init];
[mt notif:@"ARRIVING!"];
//***** If I call this method, my code won't compile!!! *****
}
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
NSLog(@"%@ will …Run Code Online (Sandbox Code Playgroud)