How To Include Record Field in CloudKit Push Notification

21 Views Asked by At

I am trying to create a push notification that can be received even if the app has been force quit (so not via a silent notification), that contains dynamic information in the alertBody.

The code I have below I'm aware is invalid, but is my ideal/dream outcome:

    let subscription = CKQuerySubscription(recordType: "FollowRequests", predicate: predicate, subscriptionID: "newFollowRequest", options: .firesOnRecordCreation)

    let notificationInfo = CKSubscription.NotificationInfo()
    notificationInfo.alertBody = "%@ sent you a follow request"
    notificationInfo.desiredKeys = ["fromUsername"]

Is there any way to achieve this, so that notifications can send dynamic data? Or if I want to use CloudKit alone for my push notifications, I can only send a static pre-defined string?

0

There are 0 best solutions below