YMPYandexMetricaPush class
The main class for push notifications handling.
Instance methods
+downloadAttachmentsForNotificationRequest: | Uploads attached files in push notifications. The method is available for iOS 10.0 and higher. |
+handleApplicationDidFinishLaunchingWithOptions: | Handles push notification openings from the method application:didFinishLaunchingWithOptions:. Method should be invoked after AppMetrica SDK initialization. |
+handleDidReceiveNotificationRequest: | Handles push notifications receiving from Notification Service Extension. |
+handleRemoteNotification: | Handles push notification openings from the method application:didReceiveRemoteNotification:fetchCompletionHandler. Method should be invoked after AppMetrica SDK initialization. |
+handleSceneWillConnectToSession: | Handles opening push notifications from the method scene:willConnectToSession:options:. Method should be invoked after AppMetrica SDK initialization. |
+isNotificationRelatedToSDK: | Returns |
+setDeviceTokenFromData: | Registers the device token for an application with a production environment. Method should be invoked after AppMetrica SDK initialization. |
+setDeviceTokenFromData:pushEnvironment: | Registers the device token of the application with the specified environment. Method should be invoked after AppMetrica SDK initialization. |
+setExtensionAppGroup: | Registers the App Groups shared group for the app and Notification Service Extension. |
+userDataForNotification: | Returns an arbitrary data string that is passed in the push notification:
|
+userNotificationCenterDelegate: | Returns a delegate YMPUserNotificationCenterDelegate, which handles foreground push notifications on iOS 10 and higher. |
+userNotificationCenterHandler: | Returns a delegate YMPUserNotificationCenterHandling, which allows you to manually handle foreground push notifications on iOS 10 and higher. |
+downloadAttachmentsForNotificationRequest: | Uploads attached files in push notifications. The method is available for iOS 10.0 and higher. |
+handleApplicationDidFinishLaunchingWithOptions: | Handles push notification openings from the method application:didFinishLaunchingWithOptions:. Method should be invoked after AppMetrica SDK initialization. |
+handleDidReceiveNotificationRequest: | Handles push notifications receiving from Notification Service Extension. |
+handleRemoteNotification: | Handles push notification openings from the method application:didReceiveRemoteNotification:fetchCompletionHandler. Method should be invoked after AppMetrica SDK initialization. |
+handleSceneWillConnectToSession: | Handles opening push notifications from the method scene:willConnectToSession:options:. Method should be invoked after AppMetrica SDK initialization. |
+isNotificationRelatedToSDK: | Returns |
+setDeviceTokenFromData: | Registers the device token for an application with a production environment. Method should be invoked after AppMetrica SDK initialization. |
+setDeviceTokenFromData:pushEnvironment: | Registers the device token of the application with the specified environment. Method should be invoked after AppMetrica SDK initialization. |
+setExtensionAppGroup: | Registers the App Groups shared group for the app and Notification Service Extension. |
+userDataForNotification: | Returns an arbitrary data string that is passed in the push notification:
|
+userNotificationCenterDelegate: | Returns a delegate YMPUserNotificationCenterDelegate, which handles foreground push notifications on iOS 10 and higher. |
+userNotificationCenterHandler: | Returns a delegate YMPUserNotificationCenterHandling, which allows you to manually handle foreground push notifications on iOS 10 and higher. |
Method descriptions
+downloadAttachmentsForNotificationRequest:
+ (void)downloadAttachmentsForNotificationRequest:(UNNotificationRequest *)request
callback:(YMPAttachmentsDownloadCallback)callback);
Uploads attached files in push notifications. The method is available for iOS 10.0 and higher.
request | The instance of UNNotificationRequest. |
callback | The callback block for uploading attached files. Format: |
request | The instance of UNNotificationRequest. |
callback | The callback block for uploading attached files. Format: |
+handleApplicationDidFinishLaunchingWithOptions:
+ (void)handleApplicationDidFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions
Handles push notification openings from the method application:didFinishLaunchingWithOptions:. Method should be invoked after AppMetrica SDK initialization.
launchOptions | Parameters as key-value pairs that contain information about the application start. |
launchOptions | Parameters as key-value pairs that contain information about the application start. |
+handleDidReceiveNotificationRequest:
+ (void)handleDidReceiveNotificationRequest:(UNNotificationRequest *)request
Handles push notifications receiving from Notification Service Extension.
You should call the method in the implementation of didReceiveNotificationRequest:withContentHandler:.
request | The instance of UNNotificationRequest. |
request | The instance of UNNotificationRequest. |
+handleRemoteNotification:
+ (void)handleRemoteNotification:(NSDictionary *)userInfo
Handles push notification openings from the method application:didReceiveRemoteNotification:fetchCompletionHandler. Method should be invoked after AppMetrica SDK initialization.
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
+handleSceneWillConnectToSession:
+ (void)handleSceneWillConnectToSessionWithOptions:(UISceneConnectionOptions *)connectionOptions
Handles opening push notifications from the method scene:willConnectToSession:options:. Method should be invoked after AppMetrica SDK initialization.
connectionOptions | The UISceneConnectionOptions class object with connection parameters that are transmitted by the system. |
connectionOptions | The UISceneConnectionOptions class object with connection parameters that are transmitted by the system. |
+isNotificationRelatedToSDK:
+ (BOOL)isNotificationRelatedToSDK:(NSDictionary *)userInfo;
Returns YES
if a push notification is related to AppMetrica.
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
Returns:
YES
— If the push notification refers to AppMetrica.NO
— If the push notification is not related to AppMetrica.
+setDeviceTokenFromData:
+ (void)setDeviceTokenFromData:(nullable NSData *)data
Registers the device token for an application with a production environment. Method should be invoked after AppMetrica SDK initialization.
data | Device token of the application. If you pass the |
data | Device token of the application. If you pass the |
+setDeviceTokenFromData:pushEnvironment:
+ (void)setDeviceTokenFromData:(nullable NSData *)data
pushEnvironment:(YMPYandexMetricaPushEnvironment)pushEnvironment
Registers the device token of the application with the specified environment. Method should be invoked after AppMetrica SDK initialization.
data | Device token of the application. If you pass the |
pushEnvironment | APNs app environment. |
data | Device token of the application. If you pass the |
pushEnvironment | APNs app environment. |
+setExtensionAppGroup:
+ (void)setExtensionAppGroup:(NSString *)appGroup
Registers the App Groups shared group for the app and Notification Service Extension.
Registration is necessary for tracking the delivery of push notifications. For more information, see Configuring statistics collection for push notifications.
appGroup | The name of the shared App Groups group. |
appGroup | The name of the shared App Groups group. |
+userDataForNotification:
+ (nullable NSString *)userDataForNotification:(NSDictionary *)userInfo
- In the Additional data field when sending from the AppMetrica interface.
- In the
data
field when sending using the Push API.
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
userInfo | Parameters of push notifications as key-value pairs that are transmitted by the system. |
Returns:
An arbitrary data string.
+userNotificationCenterDelegate
+ (id<YMPUserNotificationCenterDelegate>)userNotificationCenterDelegate
Returns a delegate YMPUserNotificationCenterDelegate, which handles foreground push notifications on iOS 10 and higher.
To handle foreground push notifications, add this code to the application: didFinishLaunchingWithOptions: method:
[UNUserNotificationCenter currentNotificationCenter].delegate = [YMPYandexMetricaPush userNotificationCenterDelegate];
For manual handling of push notifications, use +userNotificationCenterHandler.
Returns:
A delegate that implements the YMPUserNotificationCenterDelegate protocol.
+userNotificationCenterHandler
+ (id<YMPUserNotificationCenterHandling>)userNotificationCenterHandler
Returns a delegate YMPUserNotificationCenterHandling, which allows you to manually handle foreground push notifications on iOS 10 and higher.
Use this delegate if you implement the UNUserNotificationCenterDelegate protocol with custom logic. In this case, you should implement all methods of the UNUserNotificationCenterDelegate
delegate and call the corresponding methods in YMPUserNotificationCenterHandling
.
For simplified push notification handling, use +userNotificationCenterDelegate.
Returns:
A delegate that implements the YMPUserNotificationCenterHandling
protocol.