앱을 만들고 PushKit Voip을 추가했습니다. 내가 컴파일하고 Xcode에서 모든 것을 잘 실행하면 푸시를받을 수 있습니다.PushKit Voip을 테스트하려면 어떻게해야합니까?
그러나 TestFlight에서 설치하면 푸시가 실행되지 않습니다.
왜? 나는 그들에게 같은 길을 보냈다.
앱을 만들고 PushKit Voip을 추가했습니다. 내가 컴파일하고 Xcode에서 모든 것을 잘 실행하면 푸시를받을 수 있습니다.PushKit Voip을 테스트하려면 어떻게해야합니까?
그러나 TestFlight에서 설치하면 푸시가 실행되지 않습니다.
왜? 나는 그들에게 같은 길을 보냈다.
묵음 푸시 알림 페이로드를 받으면 자동 푸시 알림이 알림 센터에 표시되지 않으므로 로컬 알림을 예약해야합니다. 최대 30 초 동안 로컬 알림 사운드 파일이 재생 될 때까지 응용 프로그램이 백그라운드에서 호출되거나 종료 상태가됩니다. UI 활동이 아닌 여기에서 활동을 요구할 수 있습니다.
대화 형 로컬 알림을 누르면 더 많은 UI 작업을 수행 할 수 있습니다.
구조를 사용하여 작업을 수행하십시오.
사용
<?php
// Put your device token here (without spaces):
$deviceToken = '123456789';
//
// Put your private key's passphrase here:
$passphrase = 'ProjectName';
// Put your alert message here:
$message = 'My first push notification!';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'PemFileName.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
// 'ssl://gateway.push.apple.com:2195', $err,
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'content-available'=> 1,
'alert' => $message,
'sound' => 'default',
'badge' => 0,
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
// Close the connection to the server
fclose($fp);
사용 아래이 simplepush.php 파일 위치 및 화재 명령을 simplepush.php로 이동 PEM 파일을 생성하고 그 후 위의 코드
$ openssl x509 -in aps_development.cer -inform der -out PushCert.pem
# Convert .p12 to .pem. Enter your pass pharse which is the same pwd that you have given while creating the .p12 certificate. PEM pass phrase also same as .p12 cert.
$ openssl pkcs12 -nocerts -out PushKey1.pem -in pushkey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
# To remove passpharse for the key to access globally. This only solved my stream_socket_client() & certificate capath warnings.
$ openssl rsa -in PushKey1.pem -out PushKey1_Rmv.pem
Enter pass phrase for PushChatKey1.pem:
writing RSA key
# To join the two .pem file into one file:
$ cat PushCert.pem PushKey1_Rmv.pem > ApnsDev.pem
에서 사용하는 명령 -> php simplepush.php
이렇게하면 푸시 킷 알림 설정 아키텍처를 테스트 할 수 있습니다. 만약 당신이 설치 소켓 아키텍처 병행 Download
import UIKit
import PushKit
class AppDelegate: UIResponder, UIApplicationDelegate,PKPushRegistryDelegate{
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
// From here you have to schedule your local notification
}
}
https://www.raywenderlich.com/123862/push-notifications-tutorial
. 그런 다음 소켓은 사용자가 온라인/오프라인으로 데이터를 브로드 캐스팅하는 데 사용되며 API를 호출하지 않고 소켓을 사용할 수 있어야합니다. 서버의 소켓 아키텍처는 기기에서 요청하지 않고 온라인/오프라인 사용자의 데이터를 기기로 전송합니다.어딘가에 내가 도와 줄 수 있는지 알려주세요.
행복한 코딩.
testflight에 아무런 문제가 없습니다. 일치하지 않거나 testflight로 앱을 만드는 동안 제대로 구성되지 않은 인증서 및 파일에 문제가 있습니다. – Hasya
@ 하야, 필요한 인증서가 무엇인지 어떻게 알 수 있습니까? 나는 모두 제거하고 새로운 것을 추가하는 것을 의미합니까? – user7065798
시도 했습니까? – Hasya