2015-01-15 5 views
0

테스트 프로젝트에서 구문 분석을 사용하여 푸시 알림을 설정하려고합니다.구문 분석 클라이언트 측 푸시 알림을 설정하는 방법

나는 푸시 설정 가이드/가이드를 따라 왔습니다.

구문 분석 대시 보드에서 클라이언트 푸시를 사용할 수 있도록 설정했습니다. enter image description here

내가 대상 및 프로젝트에 대한 빌드 설정에서 코드 서명 설정을 설정 한 .plist

을 업데이트했습니다. 내가

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) 

유무 I 설정 내 프로비저닝 프로파일과에서 나는 다음과 같은 오류

Error Domain=Parse Code=115 "The operation couldn’t be completed. (Parse error 115.)" UserInfo=0x1764cad0 {code=115, error=Client-initiated push isn't enabled.} 

을 얻을 푸시를 보낼 때

PFPush.sendPushMessageToChannelInBackground("global", withMessage: "First push ever") { (success: Bool!, error: NSError!) -> Void in 
... 
} 

:

나는에 의해 푸시를 보내 인증서가 잘못 되었습니까? 이것을 확인하는 방법이 있습니까? appDelegate에서 구문 분석을 잘못 설정 했습니까? 이것을 확인하는 방법이 있습니까?

내 애플 대리인은 다음과 같습니다

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
Parse.setApplicationId("xxx", clientKey: "xxx") 
var userNotificationTypes = (UIUserNotificationType.Alert | UIUserNotificationType.Badge) 
var settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil) 
application.registerUserNotificationSettings(settings) 
application.registerForRemoteNotifications() 
return true 
} 

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { 
var currentInstallation = PFInstallation.currentInstallation() 
currentInstallation.setDeviceTokenFromData(deviceToken) 
currentInstallation.channels = ["global"] 
currentInstallation.save() 
} 

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { 
if error != nil { 
    println(error) 
} 
} 

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) { 
PFPush.handlePush(userInfo) 
} 

func applicationDidBecomeActive(application: UIApplication) { 
var currentInstallation = PFInstallation.currentInstallation() 
if currentInstallation.badge != 0 { 
currentInstallation.badge = 0 
currentInstallation.saveEventually() 
} 
+0

어떻게 푸시 알림을 보내려고합니까? Swift 사용을 시작하지는 않았지만 코드를 살펴보면 클라이언트에서 푸시 알림을 보내는 위치를 알 수 없습니다. 앱이 다른 기기에 푸시 알림을 보내는 경우에만 '클라이언트 푸시 사용'을 활성화해야합니다. –

+0

푸시 요청을 포함하도록 질문을 업데이트했습니다. – grabury

+0

오류 115은 푸시가 서버에서 잘못 구성되었다는 것을 의미합니다. Parse에서 인증서를 구성 했습니까? 그리고 그들은 올바른 유형입니까 (dev vs prod)? 구문 분석은 푸시 영역에서 어떤 유형의 인증서를 업로드했는지 알려주고 앱 빌드가 동일한 유형을 사용하는지 확인해야합니다. – rickerbh

답변

1

당신은 클라이언트가 애플 대리자에서 밀어 보내지 마십시오. 당신은 푸시를 촉발시키는 행동에서 그들을 보냅니다.

// Create our Installation query 
PFQuery *pushQuery = [PFInstallation query]; 
[pushQuery whereKey:@"channels" equalTo:@"Giants"]; // Set channel 
[pushQuery whereKey:@"scores" equalTo:YES]; 

// Send push notification to query 
PFPush *push = [[PFPush alloc] init]; 
[push setQuery:pushQuery]; 
[push setMessage:@"Giants scored against the A's! It's now 2-2."]; 
[push sendPushInBackground]; 

그리고 당신은 앱 스토어에이 응용 프로그램을 출시 할 계획하는 경우 참고하시기 바랍니다, 당신이 밀어 클라이언트 측을 처리하기 위해 클라우드 코드를 사용한다, 직접 이유는 여기에

은 목표 C의 예입니다 클라이언트에서 클라이언트로 보안 취약성까지 앱을 푸시합니다.

관련 문제