iPhone없이 Apple 푸시 알림 서비스를 테스트하려면 어떻게해야합니까?
iPhone 애플리케이션없이 Apple Push Notification Services를 테스트 할 수 있습니까? (Windows에서 에뮬레이터를 만드시겠습니까?)
그렇지 않은 경우 어떻게 테스트 할 수 있습니까? 이를 위해 컴파일 된 무료 샘플 애플리케이션이 있습니까?
서버 공급자를 만들었지 만 기능을 테스트해야합니다.
(이 답변은 2013 년 이후에 만료 될 수 있습니다.)
죄송합니다.이 기능을 테스트하려면 하드웨어를 찾아야합니다.
시뮬레이터에서는 푸시 알림을 사용할 수 없습니다. iTunes Connect의 프로비저닝 프로파일이 필요하므로 장치에 설치해야합니다. 그것은 또한 당신이 아마도 애플 아이폰 개발자 프로그램에 가입하고 $ 99를 지불해야한다는 것을 의미합니다.
밝은면에서는 iPhone OS 3.0 업데이트를 통해 1 세대 iPhone을 포함한 모든 장치에서이 기능을 테스트 할 수 있습니다.
실제 푸시 알림은 테스트 할 수 없습니다. 그러나 프로그래밍 방식으로 하나를 만들고 AppDelegate의 메서드를 수동으로 트리거하여 시뮬레이션 된 푸시 알림에 대한 앱의 응답 을 테스트 할 수 있습니다 - application:application didReceiveRemoteNotification:notification
.
다른 클래스 (예 : UIViewController)에서이를 트리거하려면 :
[[[UIApplication sharedApplication] delegate]
application:[UIApplication sharedApplication]
didReceiveRemoteNotification:testNotification];
testNotification은 실제 알림과 동일한 형식이어야합니다. 즉, 속성 목록 개체와 NSNull을 포함하는 NSDictionary입니다.
testNotification
위의 정보 를 제공하는 방법의 예는 다음과 같습니다 .
NSMutableDictionary *notification = [[NSMutableDictionary alloc] init];
[notification setValue:@"Test" forKey:@"alert"];
[notification setValue:@"default" forKey:@"sound"];
NSMutableDictionary *testNotification = [[NSMutableDictionary alloc] init];
[testNotification setValue:notification forKey:@"aps"];
작업 할 합리적인 알림 NSDictionary를 만들어야합니다.
요즘에는 이 라이브러리로 푸시 알림을 테스트 할 수 있습니다 .
터미널을 통해 푸시를 보내는 것은 매우 쉽습니다.
echo -n '{"message":"message"}' | nc -4u -w1 localhost 9930
echo -n '{"aps":{"alert" : "message","badge" : 99,"sound" : "default"}, "myField" : 54758}' | nc -4u -w1 localhost 9930
시뮬레이터는 푸시 알림을 수행하지 않습니다.
서버에서 푸시하려면 푸시 할 디바이스와 해당 디바이스의 앱이 있어야합니다.
토큰에는 앱 ID와 기기 ID가 포함됩니다.
당신은 사용해야합니다
NSString *notificationString = @"{\"aps\":{\"alert\":\"Test alert\",\"sound\":\"default\"}}";
NSData *notificationData = [notificationString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *testNotification = [NSJSONSerialization JSONObjectWithData:notificationData options:0 error:&error];
[[[UIApplication sharedApplication] delegate] application:[UIApplication sharedApplication] didReceiveRemoteNotification:testNotification fetchCompletionHandler:nil];
예, 시뮬레이터에서 푸시 알림을 확인할 수 있지만 앱 이름 SimulatorRemoteNotifications 에서 라이브러리를 사용해야합니다 . 4 ~ 5 단계 만 사용하면 Simulator에서 푸시 알림을 테스트 할 수 있습니다.
그들은 또한 POD를 제공합니다
pod 'SimulatorRemoteNotifications', '~> 0.0.3'
'Nice programing' 카테고리의 다른 글
BREW 오류 : 심볼릭 링크 불가, 경로 쓰기 불가 (0) | 2020.11.16 |
---|---|
What does 'extended' mean in express 4.0? (0) | 2020.11.16 |
HashMap : 하나의 키, 여러 값 (0) | 2020.11.16 |
Collections.synchronizedList 및 동기화 됨 (0) | 2020.11.16 |
printStackTrace (); 피하십시오. (0) | 2020.11.16 |