콘텐츠로 건너뛰기

Cordova 플러그인 API 레퍼런스

예시
var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
// pushwoosh.onDeviceReady 전에 호출해야 합니다
document.addEventListener('push-notification', function(event) {
var notification = event.notification;
// 여기에서 푸시 오픈을 처리합니다
});
// Pushwoosh를 초기화합니다. 시작 시 모든 보류 중인 푸시 알림을 트리거합니다.
pushwoosh.onDeviceReady({
appid: "XXXXX-XXXXX",
projectid: "XXXXXXXXXXXXXXX",
serviceName: "XXXX"
});
pushwoosh.registerDevice(
function(status) {
var pushToken = status.pushToken;
// 여기에서 성공적인 등록을 처리합니다
},
function(status) {
// 여기에서 등록 오류를 처리합니다
}
);

onDeviceReady

Anchor link to
PushNotification.prototype.onDeviceReady = function( config )

[android, ios, wp8, windows]
Pushwoosh 플러그인을 초기화하고 시작 푸시 메시지를 트리거합니다. 모든 앱 실행 시 호출해야 합니다.

config.appid – Pushwoosh 애플리케이션 코드입니다.

config.projectid – Android 플랫폼용 GCM 프로젝트 번호입니다.

config.serviceName – wp8 플랫폼용 MPNS 서비스 이름입니다.

예시
// projectid: "GOOGLE_PROJECT_NUMBER", appid : "PUSHWOOSH_APP_ID", serviceName : "WINDOWS_PHONE_SERVICE"로 Pushwoosh를 초기화합니다. 시작 시 모든 보류 중인 푸시 알림을 트리거합니다.
pushwoosh.onDeviceReady({
appid : "XXXXX-XXXXX",
projectid: "XXXXXXXXXXXXXXX",
serviceName: "XXXX"
});

registerDevice

Anchor link to
PushNotification.prototype.registerDevice = function( success, fail )

[android, ios, wp8, windows]
푸시 알림을 위해 기기를 등록하고 푸시 토큰을 검색합니다.

success – 성공 콜백입니다. 푸시 토큰은 이 콜백에 “status.pushToken” 매개변수로 전달됩니다.

fail – 오류 콜백입니다.

예시
pushwoosh.registerDevice(
function(status) {
alert("푸시 토큰으로 등록됨: " + status.pushToken);
},
function(error) {
alert("등록 실패: " + error);
}
);

unregisterDevice

Anchor link to
PushNotification.prototype.unregisterDevice = function( success, fail )

[android, ios, wp8, windows]
푸시 알림 수신에서 기기를 등록 해제합니다.

success – 성공 콜백입니다.

fail – 오류 콜백입니다.

PushNotification.prototype.setTags = function( config, success, fail )

[android, ios, wp8, windows]
기기에 대한 태그를 설정합니다.

매개변수

config – 사용자 지정 기기 태그가 있는 객체입니다.

success – 성공 콜백입니다. 푸시 토큰은 이 콜백에 “status.pushToken” 매개변수로 전달됩니다.

fail – 오류 콜백입니다.

예시
// 태그를 설정합니다: “deviceName”에 값 “hello”, “deviceId”에 값 10
pushwoosh.setTags({deviceName:"hello", deviceId:10},
function() {
console.warn('setTags 성공');
},
function(error) {
console.warn('setTags 실패');
}
);
// 리스트 태그 "MyTag"에 값 (배열) "hello", "world"를 설정합니다
pushwoosh.setTags({"MyTag":["hello", "world"]});
PushNotification.prototype.getTags = function( success, fail )

[android, ios, wp8, windows]
기본 태그를 포함하여 기기에 대한 태그를 반환합니다.

success – 성공 콜백입니다. 태그를 매개변수로 받습니다.

fail – 오류 콜백입니다.

pushwoosh.getTags(
function(tags) {
console.warn('기기 태그: ' + JSON.stringify(tags));
},
function(error) {
console.warn('태그 가져오기 오류: ' + JSON.stringify(error));
}
);

getPushToken

Anchor link to
PushNotification.prototype.getPushToken = function( success )

[android, ios, wp8, windows]
푸시 토큰이 사용 가능한 경우 반환합니다. 토큰은 registerDevice 함수 콜백에서도 제공됩니다.

success – 성공 콜백입니다.

pushwoosh.getPushToken(
function(token) {
console.warn('푸시 토큰: ' + token);
}
);

getPushwooshHWID

Anchor link to
PushNotification.prototype.getPushwooshHWID = function( success )

[android, ios, wp8, windows]
Pushwoosh API와의 통신에 사용되는 Pushwoosh HWID를 반환합니다.

successgetPushwooshHWID 콜백입니다.

pushwoosh.getPushwooshHWID(
function(token) {
console.warn('Pushwoosh HWID: ' + token);
}
);

getRemoteNotificationStatus

Anchor link to
PushNotification.prototype.getRemoteNotificationStatus = function( callback, error )

[android, ios]
푸시 알림 권한의 상세 상태를 반환합니다.

callback – 성공 콜백입니다. 다음 속성을 가진 객체를 받습니다:

{
"enabled" : 알림 활성화 플래그입니다.
"pushBadge" : 배지 권한이 부여되었습니다. (iOS 전용)
"pushAlert" : 알림 권한이 부여되었습니다. (iOS 전용)
"pushSound" : 사운드 권한이 부여되었습니다. (iOS 전용)
}

error — 오류 콜백입니다.

setApplicationIconBadgeNumber

Anchor link to
PushNotification.prototype.setApplicationIconBadgeNumber = function( badgeNumber )

[android, ios]
애플리케이션 아이콘 배지 번호를 설정합니다.

badgeNumber – 아이콘 배지 번호입니다.

getApplicationIconBadgeNumber

Anchor link to
PushNotification.prototype.getApplicationIconBadgeNumber = function( callback )

[android, ios]
애플리케이션 아이콘 배지 번호를 반환합니다.

callback – 성공 콜백입니다.

pushwoosh.getApplicationIconBadgeNumber(function(badge){ alert(badge);} );

addToApplicationIconBadgeNumber

Anchor link to
PushNotification.prototype.addToApplicationIconBadgeNumber = function( badgeNumber )

[android, ios]
애플리케이션 아이콘 배지에 값을 추가합니다.

badgeNumber — 증분 아이콘 배지 번호입니다.

getLaunchNotification

Anchor link to
PushNotification.prototype.getLaunchNotification = function( callback )

[android, ios]
앱이 푸시 알림에 응답하여 시작된 경우 푸시 알림 페이로드를 반환하고, 그렇지 않으면 null을 반환합니다.

callback – 성공 콜백입니다.

clearLaunchNotification

Anchor link to
PushNotification.prototype.clearLaunchNotification = function( callback )

[android, ios]
시작 알림을 지웁니다. 이 호출 후 getLaunchNotification()은 null을 반환합니다.

PushNotification.prototype.setUserId = function( userId )

[android, ios]
사용자 식별자(Facebook ID, 사용자 이름, 이메일 또는 기타 사용자 ID)를 설정합니다. 이를 통해 여러 사용자 기기에서 데이터와 이벤트를 일치시킬 수 있습니다.

userId – 사용자 문자열 식별자입니다.

PushNotification.prototype.postEvent = function( event, attributes )

[android, ios]
인앱 메시지에 대한 이벤트를 게시합니다. 이는 Pushwoosh 제어판에 지정된 대로 인앱 메시지 표시를 트리거할 수 있습니다.

event – 트리거할 이벤트입니다.

attributes – 추가 이벤트 속성이 있는 객체입니다.

pushwoosh.setUserId("XXXXXX");
pushwoosh.postEvent("buttonPressed", { "buttonNumber" : 4, "buttonLabel" : "banner" });

createLocalNotification

Anchor link to
PushNotification.prototype.createLocalNotification = function( config, success, fail )

[android, ios]
로컬 알림을 예약합니다.

config.msg – 알림 메시지입니다.

config.seconds – 초 단위의 알림 지연 시간입니다.

config.userData – 알림에 전달할 추가 데이터입니다.

success – 성공 콜백입니다.

fail – 오류 콜백입니다.

pushwoosh.createLocalNotification({msg:"호박이 준비되었습니다!", seconds:30, userData:{}})

clearLocalNotification

Anchor link to
PushNotification.prototype.clearLocalNotification = function()

[android]
createLocalNotification으로 생성된 모든 보류 중인 로컬 알림을 지웁니다.

clearNotificationCenter

Anchor link to
PushNotification.prototype.clearNotificationCenter = function()

[android]
Android 알림 센터에 표시된 모든 알림을 지웁니다.

setMultiNotificationMode

Anchor link to
PushNotification.prototype.setMultiNotificationMode = function( success, fail )

[android]
Android 알림 센터에 여러 알림을 표시할 수 있도록 허용합니다.

setSingleNotificationMode

Anchor link to
PushNotification.prototype.setSingleNotificationMode = function( success,
fail )

[android]
Android 알림 센터에 마지막 알림만 표시되도록 허용합니다.

setSoundType

Anchor link to
PushNotification.prototype.setSoundType = function( type, success, fail )

[android]
수신 푸시에 대한 기본 사운드를 설정합니다.

type – 사운드 유형 (0 – 기본값, 1 – 소리 없음, 2 – 항상)

setVibrateType

Anchor link to
PushNotification.prototype.setVibrateType = function(type, success, fail )

[android]
수신 푸시에 대한 기본 진동 모드를 설정합니다.

type – 진동 유형 (0 – 기본값, 1 – 진동 없음, 2 – 항상)

setLightScreenOnNotification

Anchor link to
PushNotification.prototype.setLightScreenOnNotification = function( on, success, fail )

[android]
알림이 도착하면 화면을 켭니다.

on – 화면 잠금 해제 활성화/비활성화 (기본적으로 비활성화됨)

setEnableLED

Anchor link to
PushNotification.prototype.setEnableLED = function( on, success, fail )

[android]
알림이 도착하고 디스플레이가 꺼져 있을 때 LED 깜박임을 활성화합니다.

on – LED 깜박임 활성화/비활성화 (기본적으로 비활성화됨)

setColorLED

Anchor link to
PushNotification.prototype.setColorLED = function( color, success, fail )

[android]
LED 색상을 설정합니다. setEnableLED와 함께 사용하세요.

color – ARGB 정수 형식의 LED 색상입니다.

getPushHistory

Anchor link to
PushNotification.prototype.getPushHistory = function( success )

[android]
수신된 푸시 알림의 배열을 반환합니다.

success – 성공 콜백입니다.

pushwoosh.getPushHistory(function(pushHistory) {
if(pushHistory.length == 0)
alert("푸시 기록 없음");
else
alert(JSON.stringify(pushHistory));
});
pushwoosh.clearPushHistory();

clearPushHistory

Anchor link to
PushNotification.prototype.clearPushHistory = function()

[android]
푸시 기록을 지웁니다.

cancelAllLocalNotifications

Anchor link to
PushNotification.prototype.cancelAllLocalNotifications = function( callback )

[ios]
알림 센터에서 모든 로컬 알림을 지웁니다.

presentInboxUI

Anchor link to

[android, ios]
받은 편지함 화면을 엽니다.

PushNotification.prototype.presentInboxUI = function()

setCommunicationEnabled

Anchor link to

Pushwoosh와의 모든 통신을 활성화/비활성화하는 이진 메서드입니다. 부울 값이 false이면 기기가 푸시 알림 수신을 구독 취소하고 인앱 메시지 다운로드를 중지합니다. 값 true는 효과를 반전시킵니다.

PushNotification.prototype.setCommunicationEnabled = function(enable, success, fail)

removeAllDeviceData

Anchor link to

기기에 대한 모든 데이터를 제거합니다.

PushNotification.prototype.removeAllDeviceData = function()

push-receive

Anchor link to

[android, ios]
푸시 알림 수신 이벤트입니다. 애플리케이션이 포그라운드 또는 백그라운드에서 푸시 알림을 수신할 때 발생합니다. 닫힌 애플리케이션은 이 이벤트를 수신하지 않습니다.

이벤트 속성

message – (string) 푸시 알림 메시지

userdata – (object/array) 푸시 알림 사용자 지정 데이터

onStart – (boolean) 시작 알림 여부

foreground – (boolean) 포그라운드에서 수신된 알림 여부

android – (object) Android 특정 알림 페이로드

ios – (object) iOS 특정 알림 페이로드

windows – (object) Windows 특정 알림 페이로드

document.addEventListener('push-receive',
function(event) {
var userData = event.notification.userdata;
if (typeof(userData) != "undefined") {
// 사용자 지정 알림 데이터 처리
console.warn('사용자 데이터: ' + JSON.stringify(userData));
}
}
);

포그라운드 알림

Anchor link to

기본적으로 Pushwoosh 플러그인은 포그라운드에서 알림을 표시하지 않고 자동으로 push-receive 이벤트를 트리거합니다. 이 동작을 제어하려면 플러그인 사용자 지정 가이드를 참조하세요.

push-notification

Anchor link to

[android, ios, wp8, windows]
푸시 알림 수락 이벤트입니다. 사용자가 푸시 알림을 탭할 때 발생합니다.

document.addEventListener('push-notification',
function(event) {
var message = event.notification.message;
var userData = event.notification.userdata;
if (typeof(userData) != "undefined") {
console.warn('사용자 데이터: ' + JSON.stringify(userData));
}
}
);

이벤트 속성

push-receive와 동일

additionalAuthorizationOptions

Anchor link to

[ios 전용]
추가적인 알림 승인 옵션을 제공합니다. registerDevice를 호출하기 전에 호출해야 합니다.

pushwoosh.additionalAuthorizationOptions({
"UNAuthorizationOptionCriticalAlert" : 1,
"UNAuthorizationOptionProvisional": 0 // 앱에 추가하고 싶지 않은 경우 0으로 설정하거나 옵션을 지정하지 마세요.
});