2017-02-02 35 views
0

私のアプリケーションにvoipプッシュサポートを追加します。私はlinkの手順に従った。 hustonからプッシュを送信すると、「1プッシュ通知が正常に送信されました」と表示されます。私はamazon snを使用して同じことを試みました。プッシュが正常に公開されたと同じですが、プッシュがレジストリの代理人、つまりdidReceiveIncomingPushWithPayloadで受信されていません。私はvoip配信プロファイルを使ってこれを試しました。 ご協力いただければ幸いです。iosデバイスでVoipプッシュを受信して​​いません

+0

解決しましたか? – Hasya

答えて

1

Hereは、VOIPの手順に従う1つのリンクです。

通知が届くと、didReceiveIncomingPushWithPayloadが呼び出されます。そこからのローカル通知でユーザーに通知できます。

+0

応答のおかげで、私はログを印刷しようとしましたが、それは動作していませんでした。しかし、ローカルの通知を追加すると、私はそれが動作して参照してください。 – devdev

0

リファレンス https://github.com/hasyapanchasara/PushKit_SilentPushNotification

オブジェクティブCとスウィフトコードの両方があります。

証明書、コードを確認し、voip(サイレント)プッシュ通知を送信するだけです。

import UIKit 
import PushKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate,PKPushRegistryDelegate { 

var window: UIWindow? 


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 


    let types: UIRemoteNotificationType = [.Alert, .Badge, .Sound] 
    application.registerForRemoteNotificationTypes(types) 

    self.PushKitRegistration() 

    return true 
} 

//MARK: - PushKitRegistration 

func PushKitRegistration() 
{ 

    let mainQueue = dispatch_get_main_queue() 
    // Create a push registry object 
    if #available(iOS 8.0, *) { 

     let voipRegistry: PKPushRegistry = PKPushRegistry(queue: mainQueue) 

     // Set the registry's delegate to self 

     voipRegistry.delegate = self 

     // Set the push type to VoIP 

     voipRegistry.desiredPushTypes = [PKPushTypeVoIP] 

    } else { 
     // Fallback on earlier versions 
    } 


} 


@available(iOS 8.0, *) 
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) { 
    // Register VoIP push token (a property of PKPushCredentials) with server 

    let hexString : String = UnsafeBufferPointer<UInt8>(start: UnsafePointer(credentials.token.bytes), 
     count: credentials.token.length).map { String(format: "%02x", $0) }.joinWithSeparator("") 

    print(hexString) 


} 


@available(iOS 8.0, *) 
func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) { 
    // Process the received push 


} 


func applicationWillResignActive(application: UIApplication) { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
} 

func applicationDidEnterBackground(application: UIApplication) { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

func applicationWillEnterForeground(application: UIApplication) { 
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 
} 

func applicationDidBecomeActive(application: UIApplication) { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 

func applicationWillTerminate(application: UIApplication) { 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 


} 

幸いコーディングしてください。

関連する問題