Link Search Menu Expand Document

Push notification service

Triggers send subscriptions events to your your app using Apple Push Notification Service.

  1. Select an optional payload to be sent with the notification.
  2. 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 will take 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 Tokenas 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 notification, you need to add it as capabilities under Signing & Capabilities tab of your target and implement related methods.

Additional information can be found on Apple documentation.

APNs payload
{
   "aps" : {
      "content-available" : 1
   },
   "offering" : "OPTIONAL_OFFERING",
}

Copyright © 2021 Glassfy.