我使用空白应用Parse下载和back4app。我将客户端和应用程序ID放在AppDelegate
上并运行应用程序,但是我收到以下错误:
" 2016-07-26 11:08:29.681 ParseStarterProject-Swift [1464:107722] [错误]:未授权(代码:0,版本:1.12.0)2016-07-26 11:08:29.682 ParseStarterProject-Swift [1464:107719] [错误]:无法 最终运行命令有错误:错误Domain = Parse Code = 0 "未授权"的UserInfo = {误差=未经授权的, NSLocalizedDescription =未授权,临时= 0}"
ViewController为空
的AppDelegate:
import UIKit
import Parse
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
//--------------------------------------
// MARK: - UIApplicationDelegate
//--------------------------------------
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Enable storing and querying data from Local Datastore.
// Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
Parse.enableLocalDatastore()
Parse.setApplicationId("ciBn93EohqEq7WLJEAByrrVFfR6B3Fu98UJgRteY",clientKey: "KHKJgfJhSLAktjqmKHRhlaUtBhtzZELsdwexpIdf")
PFUser.enableAutomaticUser()
let defaultACL = PFACL();
// If you would like all objects to be private by default, remove this line.
defaultACL.publicReadAccess = true
PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser: true)
if application.applicationState != UIApplicationState.Background {
// Track an app open here if we launch with a push, unless
// "content_available" was used to trigger a background push (introduced in iOS 7).
// In that case, we skip tracking here to avoid double counting the app-open.
let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
var noPushPayload = false;
if let options = launchOptions {
noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
}
if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
}
}
return true
}
//--------------------------------------
// MARK: Push Notifications
//--------------------------------------
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let installation = PFInstallation.currentInstallation()
installation.setDeviceTokenFromData(deviceToken)
installation.saveInBackground()
PFPush.subscribeToChannelInBackground("") { (succeeded: Bool, error: NSError?) in
if succeeded {
print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n");
} else {
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
}
}
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
if error.code == 3010 {
print("Push notifications are not supported in the iOS Simulator.\n")
} else {
print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)
}
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
PFPush.handlePush(userInfo)
if application.applicationState == UIApplicationState.Inactive {
PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
}
}
}
由于
答案 0 :(得分:1)
我发现你应该做什么,只是改变
此
Parse.setApplicationId("APP_ID",clientKey: "CLIENT_KEY")
有了这个
let configuration = ParseClientConfiguration{
$0.applicationId = "APP_ID"
$0.clientKey = "CLIENT_KEY"
$0.server = "https://parseapi.back4app.com/"
}
服务器地址仍然相同
答案 1 :(得分:0)
我觉得appid和客户端密钥肯定有问题。