首页 > 解决方案 > 将 VOIP 通知负载转换为字符串

问题描述

我正在尝试在我的应用程序中调试 VOIP 通知,但无法使用开发人员模式进行调试。当我收到通知时,我必须使用呼叫者详细信息和信息致电我的 VOIP 客户端。如何将此数据转换为字符串,类似于JSON.stringifyjavascript 中的内容?这是我的代码

// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
  // Process the received push
  [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];

  // Need to extract caller name and other details from VOIP notification payload to store into handle and callerName
  // Maybe can convert payload to string and assigning it to handle for checking it's structure

  NSString *handle = @"ateev"; // hardcoded
  NSString *uuid = [[NSUUID UUID] UUIDString];
  NSString *callerName = @"ateev"; // hardcoded
  // NSString *handle = @"caller number here";

  [RNCallKeep reportNewIncomingCall: uuid
                             handle: handle
                         handleType: @"generic"
                           hasVideo: NO
                localizedCallerName: callerName
                    supportsHolding: YES
                       supportsDTMF: YES
                   supportsGrouping: YES
                 supportsUngrouping: YES
                        fromPushKit: YES
                            payload: nil
              withCompletionHandler: completion];
  completion();
}

标签: objective-c

解决方案


推荐阅读