Как я могу получать сообщения в voip? - PullRequest
0 голосов
/ 18 мая 2018

Как я могу получать сообщения в voip?Я могу получить токен Voip!

Я пишу в Objective c:

Я искал в itnernet, но не могу найти никакого разрешения!все, что я нашел, это Swift, но я не могу получить токен в swift, но цель - получить токен, но не получить сообщения из строки.

apn push "" -c backgroundfetch.pem -m "Hello"

Как я могу открыть сообщения в Objective c?вот мой код

#import "AppDelegate.h"
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@import PushKit;
@import UserNotifications;

@interface AppDelegate ()

@end

@implementation AppDelegate


NSString *fcmToken = @"";

// Trigger VoIP registration on launch
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self voipRegistration];
    return YES;
}

// Register for VoIP notifications
- (void) voipRegistration {
    dispatch_queue_t mainQueue = dispatch_get_main_queue();
    // Create a push registry object
    PKPushRegistry * voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
    // Set the registry's delegate to self
    voipRegistry.delegate = self;
    // Set the push type to VoIP
    voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type{
    if([credentials.token length] == 0) {
        NSLog(@"voip token NULL");
        return;
    }

    NSLog(@"PushCredentials: %@", credentials.token);
}


// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type {
    // Process the received push
    NSLog(@"Get");
}



@end

мой info.plist:

<key>UIBackgroundModes</key>
<array>
    <string>voip</string>
    <string>audio</string>
    <string>fetch</string>
    <string>remote-notification</string>
</array>

1 Ответ

0 голосов
/ 21 мая 2018

В вашем случае решение состоит в том, чтобы отправить тихое push-уведомление.Как только приходит тихое push-уведомление, выполните ваш код с фоновой задачей.

Вот хорошее объяснение для отправки тихого push-уведомления.

https://stackoverflow.com/a/36327058/9106403

...