### Accessing the PushNotificationsService Instance Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationsService.html The syntax for the static class definition and the Instance property used to access the SDK functionality. ```csharp public static class PushNotificationsService ``` ```csharp public static IPushNotificationsService Instance { get; } ``` -------------------------------- ### RegisterForPushNotificationsAsync Method Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html Registers the device for push notifications and returns the device token. ```csharp Task RegisterForPushNotificationsAsync() ``` -------------------------------- ### GetAssetInstance() Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Retrieves the copy of the push notification settings persisted as an asset in the project. If no asset is available, it returns an empty settings object. ```APIDOC ## GetAssetInstance() ### Description Retrieves the copy of the settings persisted as an asset. The settings in this asset can be updated in the Editor from Project Settings > Services > Push Notifications. ### Declaration `public static PushNotificationSettings GetAssetInstance()` ### Returns - **PushNotificationSettings** - The settings persisted as an asset in the project, or a blank object if no settings are persisted. ``` -------------------------------- ### Retrieve PushNotificationSettings asset instance Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Use this method to access the persisted settings asset. If no asset exists, it returns an empty object. ```csharp public static PushNotificationSettings GetAssetInstance() ``` -------------------------------- ### PushNotificationsService.Instance Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationsService.html Retrieves the singleton instance of the Push Notifications service. This property must be accessed after the SDK has been initialized. ```APIDOC ## public static IPushNotificationsService Instance ### Description Returns the instance of the Push Notifications SDK. This is the primary entry point for accessing push notification functionality. ### Property Value - **Type**: IPushNotificationsService ### Exceptions - **Exception**: Thrown when the SDK has not been initialized. ``` -------------------------------- ### IPushNotificationsService Interface Syntax Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html The base interface definition for the Push Notifications service. ```csharp public interface IPushNotificationsService ``` -------------------------------- ### PushNotificationSettings Class Syntax Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html The class definition for PushNotificationSettings, which inherits from ScriptableObject. ```csharp public class PushNotificationSettings : ScriptableObject ``` -------------------------------- ### RegisterForPushNotificationsAsync() Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html Registers the application for push notifications using the appropriate platform-specific mechanism. This method automatically handles token retrieval and sends necessary analytics events. ```APIDOC ## RegisterForPushNotificationsAsync() ### Description Registers for push notifications with the appropriate mechanism for the current platform. This method automatically handles platform-specific intricacies of getting a push notification token and sends analytics events. ### Returns - **Task** - The device token as a string. ``` -------------------------------- ### RecordNotificationOpened Method Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsAnalytics.html This method is deprecated; use RegisterForPushNotificationsAsync instead. ```csharp void RecordNotificationOpened(Dictionary payload, bool didLaunch) ``` -------------------------------- ### Analytics Property Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html This property is obsolete and should not be used as analytics are handled automatically. ```csharp [Obsolete("Do not use this. It will be removed in a future version. Events are recorded for you automatically.")] IPushNotificationsAnalytics Analytics { get; } ``` -------------------------------- ### RecordPushTokenUpdated Method Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsAnalytics.html This method is deprecated; use RegisterForPushNotificationsAsync instead. ```csharp void RecordPushTokenUpdated(string pushToken) ``` -------------------------------- ### OnRemoteNotificationReceived Event Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html Subscribe to this event to handle remote notifications that launch or reopen the application. ```csharp event Action> OnRemoteNotificationReceived ``` -------------------------------- ### IPushNotificationsAnalytics Interface Definition Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsAnalytics.html The interface is marked as obsolete and will be removed in future versions. ```csharp [Obsolete("This interface should not be used. It will be deleted in the future version. Notification events are recorded for you automatically.")] public interface IPushNotificationsAnalytics ``` -------------------------------- ### firebaseWebApiKey Field Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Declaration for the Firebase API key used for Android FCM. ```csharp [Header("Android (Firebase) Settings")] [FormerlySerializedAs("androidApiKey")] public string firebaseWebApiKey ``` -------------------------------- ### OnRemoteNotificationReceived Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.IPushNotificationsService.html An event that triggers when a remote notification is used to launch or reopen the application. Subscriptions must be set up before calling RegisterForPushNotificationsAsync. ```APIDOC ## OnRemoteNotificationReceived ### Description Subscribe to this event to be notified when a remote notification is used to launch or reopen the app. If the application was started from a remote notification, this event will be invoked once the registration process has completed. ### Event Type - **Action>** ``` -------------------------------- ### firebaseProjectNumber Field Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Declaration for the Firebase sender ID used for Android FCM. ```csharp [FormerlySerializedAs("androidSenderId")] public string firebaseProjectNumber ``` -------------------------------- ### PushNotificationSettings Fields Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html The PushNotificationSettings class provides fields for configuring Firebase Cloud Messaging on Android. These settings are automatically retrieved by the SDK based on the current platform. ```APIDOC ## PushNotificationSettings Fields ### firebaseAppID - **Type**: string - **Description**: The application ID for a Firebase application to be used for Android's Firebase Cloud Messaging API. ### firebaseProjectID - **Type**: string - **Description**: The project ID for a Firebase project to be used for Android's Firebase Cloud Messaging API. ### firebaseProjectNumber - **Type**: string - **Description**: The sender ID to be used for Android's Firebase Cloud Messaging. ### firebaseWebApiKey - **Type**: string - **Description**: The API key for a Firebase project to be used for Android's Firebase Cloud Messaging API. ``` -------------------------------- ### firebaseProjectID Field Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Declaration for the Firebase project ID used for Android FCM. ```csharp [FormerlySerializedAs("androidProjectId")] public string firebaseProjectID ``` -------------------------------- ### firebaseAppID Field Declaration Source: https://docs.unity3d.com/Packages/com.unity.services.push-notifications%404.0/api/Unity.Services.PushNotifications.PushNotificationSettings.html Declaration for the Firebase application ID used for Android FCM. ```csharp [FormerlySerializedAs("androidApplicationId")] public string firebaseAppID ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.