diff --git a/protocol/diagrams/notifications/subscription.mmd b/protocol/diagrams/notifications/subscription.mmd
new file mode 100644
index 000000000..0db7cd7cc
--- /dev/null
+++ b/protocol/diagrams/notifications/subscription.mmd
@@ -0,0 +1,40 @@
+sequenceDiagram
+ participant M as mobile app
+ participant C as chat core
+ participant A as agent
+ participant S as SMP server
+ participant N as NTF server
+ participant APN as APN
+
+ note over M, APN: register subscription
+
+ alt register existing
+ M -->> A: on /_ntf register, for subscribed queues
+ else create new connection
+ A -->> S: NEW / JOIN
+ note over A, S: ...
Connection handshake
...
+ S -->> A: CON
+ end
+ A ->> S: NKEY nKey
+ S ->> A: NID nId
+ A ->> N: SNEW tknId dhKey (smpServer, nId, nKey)
+ N ->> A: ID subId dhKey
+ N ->> S: NSUB nId
+ S ->> N: OK [/ NMSG]
+
+ note over M, APN: notify about message
+
+ S ->> N: NMSG
+ N ->> APN: APNSMutableContent
ntfQueue, nonce
+ APN ->> M: UNMutableNotificationContent
+ note over M, S: ...
Client awaken, message is received
...
+ S ->> M: message
+ note over M: mutate notification
+
+ note over M, APN: change APN token
+
+ APN ->> M: new device token
+ M -->> C: /_ntf_sub update tkn
+ C -->> A: updateNtfToken()
+ A -->> N: TUPD tknId newDeviceToken
+ note over M, N: ...
Verify token
...
diff --git a/src/Simplex/Messaging/Notifications/Client.hs b/src/Simplex/Messaging/Notifications/Client.hs
index f7dc4fc52..3a5e8c827 100644
--- a/src/Simplex/Messaging/Notifications/Client.hs
+++ b/src/Simplex/Messaging/Notifications/Client.hs
@@ -48,7 +48,7 @@ ntfEnableCron c pKey tknId int = okNtfCommand (TCRN int) c pKey tknId
ntfCreateSubsciption :: NtfClient -> C.APrivateSignKey -> NewNtfEntity 'Subscription -> ExceptT ProtocolClientError IO (NtfSubscriptionId, C.PublicKeyX25519)
ntfCreateSubsciption c pKey newSub =
sendNtfCommand c (Just pKey) "" (SNEW newSub) >>= \case
- NRId tknId dhKey -> pure (tknId, dhKey)
+ NRId subId dhKey -> pure (subId, dhKey)
_ -> throwE PCEUnexpectedResponse
ntfCheckSubscription :: NtfClient -> C.APrivateSignKey -> NtfSubscriptionId -> ExceptT ProtocolClientError IO NtfSubStatus
diff --git a/src/Simplex/Messaging/Notifications/Protocol.hs b/src/Simplex/Messaging/Notifications/Protocol.hs
index 3640004e0..04fb3e21f 100644
--- a/src/Simplex/Messaging/Notifications/Protocol.hs
+++ b/src/Simplex/Messaging/Notifications/Protocol.hs
@@ -120,7 +120,7 @@ instance ToJSON NtfRegCode where
data NewNtfEntity (e :: NtfEntity) where
NewNtfTkn :: DeviceToken -> C.APublicVerifyKey -> C.PublicKeyX25519 -> NewNtfEntity 'Token
- NewNtfSub :: NtfTokenId -> SMPQueueNtf -> NewNtfEntity 'Subscription
+ NewNtfSub :: NtfTokenId -> SMPQueueNtf -> NewNtfEntity 'Subscription -- NtfTokenId -> C.APublicVerifyKey -> SMPQueueNtf
deriving instance Show (NewNtfEntity e)