The LSMPNSubscription class wraps the key (as an LSMPNKey object) and the specifications (as an LSMPNInfo object) of a mobile push notifications (MPN) subscription.
It represents a view on the actual MPN subscription stored on the Server's database. The LSMPNSubscription class supports operations like checking its current status, modifying the specifications and deactivating the MPN subscription.
MPN subscriptions are cached locally and the cache is stored in the LSClient instance that originated (i.e. activated or inquired) the MPN subscription. Thus, once an LSMPNSubscription object, with a certain MPN key, has been obtained from an LSCLient instance, any operation returning the same MPN subscription from the same LSClient instance will return the same LSMPNSubscription instance. On the other hand, deactivating an MPN subscription removes it from the local cache and marks its corresponding LSMPNSubscription instance as deactivated.
Moreover, the LSClient local cache survives a reconnection: if the LSClient reconnects (automatically or manually) with the same base parameters (i.e. LSConnectionInfo::pushServerURL, LSConnectionInfo::adapter and LSConnectionInfo::user), the MPN subscription cache is preserved. If one of these parameters changes, the cache is cleared and any dangling LSMPNSubscription instance is made invalid (no more operations will be possible on it).
LSMPNSubscription instances keep a reference to their originating LSClient, see client. In order for any operation to be successful, the originating LSClient must be connected at the moment the operation is executed.
Note that, while the LSMPNkey instance is constant, the LSMPNInfo instance may be replaced by calls that modify the MPN subscription's specifications, e.g. modify: (LSMPNSubscription), or activateMPN:coalescing: (LSClient) with coalescing
flag set, or by calls that update the local cache from the Server, e.g. inquireMPN: (LSClient), inquireMPNsWithStatus: (LSClient) and inquireAllMPNs (LSClient).
Since MPN subscriptions are stored on the Server on a per-device and per-app basis, under normal conditions only the device/app pair that created an MPN subscription may be accessing or modifying it or its cached LSMPNSubscription representation.
Inquires the status of the MPN subscription on the Server.
If the MPN subscription has been forcibly deactivated on the Server, the call will result in a LSPushServerException with error code 46 (subscription unknown) or 45 (device unknown, if no more subscriptions exist for this device and application).
Note that the status of an MPN subscription is never cached.
The method is blocking if executed outside of a batch, otherwise it is non-blocking: outside of a batch, it will return only after receiving the Server response. Inside a batch, the method will return immediately with nil, but the request will be processed only on batch commit (see commitBatch (LSClient)).
- Returns
- The MPN subscription status info, i.e. whether it is active or triggered, and the time when the status has been set. Contains also status info about the MPN device, i.e. whether it is active or suspended and the corresponding time.
- Exceptions
-
LSPushClientException | Thrown in case the MPN subscription has been deactivated, or in case the context is invalid (e.g. can't obtain a valid device token or app ID). |
LSPushServerException | Thrown in case the server refuses the request with a specific error code. |
LSPushConnectionException | Thrown in case of any other problem (including if the client is not connected). |
Deactivates the MPN subscription.
Once deactivated, no more mobile push (i.e. remote) notifications will be sent on table update. A deactivation has also the effect of deleting the MPN subscription.
If the MPN subscription has been forcibly deactivated on the Server, the call will result in a LSPushServerException with error code 46 (subscription unknown) or 45 (device unknown, if no more subscriptions exist for this device and application).
Note that MPN subscriptions are cached locally, see LSMPNSubscription description for more information. This method always contacts the Server and updates the related MPN subscription in the local cache.
The method is blocking if executed outside of a batch, else it is non-blocking: outside of a batch, it will return only after receiving the Server response. Inside a batch, the method will return immediately but the request will be processed only on batch commit (see commitBatch (LSClient)).
- Exceptions
-
LSPushClientException | Thrown in case the MPN subscription has already been deactivated, or in case the context is invalid (e.g. can't obtain a valid device token or app ID). |
LSPushServerException | Thrown in case the server refuses the request with a specific error code. |
LSPushConnectionException | Thrown in case of any other problem (including if the client is not connected). |
Modifies the specifications of the MPN subscription.
Once the change has been submitted to the server, the mpnInfo property is updated with the passed mpnInfo instance, whereas the MPN key remains unchanged.
If the MPN subscription has been forcibly deactivated on the Server, the call will result in a LSPushServerException with error code 46 (subscription unknown) or 45 (device unknown, if no more subscriptions exist for this device and application).
The operation works only on the current MPN subscription (i.e. the MPN subscription identified by the MPN key). No coalescence is possible with this operation: even if the new specifications had the same adapter set, data adapter, group, schema and trigger expression of another MPN subscription, this MPN subscription would remain distinct. See activateMPN:coalescing: (LSClient) for more information on coalescence.
The same limitations that apply during activation (see activateMPN:coalescing: (LSClient)) apply during modification. Additionally, moving MPN subscriptions from an adapter set to another is not allowed. This means the LSTableInfo::adapterSet field must be the same of the original MPN subscription AND the same of the current connection. If this field is nil, the adapter set of the current connection is considered as specified.
Note that MPN subscriptions are cached locally, see LSMPNSubscription description for more information. This method always contacts the Server and updates the related MPN subscription in the local cache.
The method is blocking if executed outside of a batch, otherwise it is non-blocking: outside of a batch, it will return only after receiving the Server response. Inside a batch, the method will return immediately, but the request will be processed only on batch commit (see commitBatch (LSClient)).
- Parameters
-
mpnInfo | Contains the new table and format specifications of the mobile push notifications. An unmodifiable copy of the object is stored internally. |
- Exceptions
-
LSPushClientException | Thrown in case the MPN subscription has been deactivated, or in case the context is invalid (e.g. can't obtain a valid device token or app ID). |
LSPushServerException | Thrown in case the server refuses the request with a specific error code. |
LSPushConnectionException | Thrown in case of any other problem (including if the client is not connected). |