2

我正在使用空白应用 Parse 下载和 back4app。我打开客户端和应用程序 IDAppDelegate并运行应用程序,但出现以下错误:

“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] [错误]:最终无法运行命令并出现错误:错误域=解析代码=0“未授权”用户信息={错误=未授权,NSLocalizedDescription=未授权,临时=0}”

视图控制器为空

应用委托:

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)
    }
}
}

谢谢

4

2 回答 2

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/"
    }

服务器地址还是一样

于 2016-07-27T04:45:32.420 回答
0

我认为您的 appid 和客户端密钥一定有问题。

于 2016-07-26T14:32:58.487 回答