Push notification
Triggers send subscriptions events to your your app using Apple Push Notification Service.
-
Select an optional payload to be sent with the notification.
-
In the Glassfy dashboard be sure you have configured the:
- Apple Push Notifications service p8 Key File
- Apple Push Notifications service p8 Key ID
- Apple Team ID.
Remote Notification payload
Our server takes care of sending a silent push notification to all registered devices of the subscriber subject of the trigger.
To register a device you have to ask user's permission and set its Token
as a userProperty
.
func sendDeviceTokenToServer(_ deviceToken: Data)
{
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
Glassfy.set(userProperty:.token, value: token) { prop, err in
// handle err
}
}
- (void)sendDeviceTokenToServer:(NSData *)deviceToken
{
const unsigned char *buffer = deviceToken.bytes;
NSMutableString _token = [NSMutableString stringWithCapacity:(deviceToken.length _ 2)];
for (int i = 0; i < len; ++i) {
[token appendFormat:@"%02x", buffer[i]];
}
[Glassfy setUserProperty:GYUserPropertyTypeToken value:token completion:^(GYUserProperties *p, NSError *err) {
// handle err
}];
}
To receive remote notifications, you need to add it as a capability under the Signing & Capabilities tab of your target and implement the related methods.
You can find additional information can be found in Apple's documentation.
APNs payload
{
"aps" : {
"content-available" : 1
},
"offering" : "OPTIONAL_OFFERING",
}
Updated almost 2 years ago