Class PushTarget
One device to deliver a push to: the provider that owns the device and the token that provider issued for it.
The push service names five providers: fcm, apns, huawei, wns and
web. A device reports its provider in older spellings too -- the app's
PushSubscription.getTransportId() can answer gcm, ios or hms -- so
of(String, String) accepts those and stores the service's name. A device
key from the classic Push.getPushKey(), such as cn1-fcm-TOKEN, is read by
fromDeviceKey(String).
toString() names the provider only. A token identifies one person's
device, so it stays out of anything that might reach a log.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringApple Push Notification service, for iOS.static final StringFirebase Cloud Messaging, for Android.static final StringHuawei Push Kit, for Huawei devices without Google services.static final StringWeb Push, for browsers.static final StringWindows Push Notification Services. -
Method Summary
Modifier and TypeMethodDescriptionstatic PushTargetfromDeviceKey(String deviceKey) A target from a classic device key,cn1-<provider>-<token>, as the app'sPush.getPushKey()reports it:cn1-fcm-...,cn1-gcm-...,cn1-ios-...orcn1-hms-....getToken()static PushTargetA target fortokenonprovider.toString()The provider only; the token is left out so a logged target identifies no device.
-
Field Details
-
FCM
-
APNS
-
HUAWEI
Huawei Push Kit, for Huawei devices without Google services.- See Also:
-
WNS
-
WEB
-
-
Method Details
-
of
A target fortokenonprovider.- Parameters:
provider- the provider id:fcm,apns,huawei,wnsorweb, or one of the aliasesgcm,iosandhms, in any casetoken- the provider's token for the device- Returns:
- the target, with the provider in the service's spelling
- Throws:
IllegalArgumentException- if the provider is unknown or the token is null or blank
-
fromDeviceKey
A target from a classic device key,
cn1-<provider>-<token>, as the app'sPush.getPushKey()reports it:cn1-fcm-...,cn1-gcm-...,cn1-ios-...orcn1-hms-....The prefix is removed and the provider normalized, so the result carries the bare token the provider issued.
- Parameters:
deviceKey- the key the device registered- Returns:
- the target
- Throws:
IllegalArgumentException- if the key doesn't have that form, names an unknown provider, or has no token
-
getProvider
- Returns:
- the provider, always one of
fcm,apns,huawei,wnsandweb
-
getToken
- Returns:
- the provider's token for the device
-
toString
-