docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AuthorizationRequest

    Use this to request authorization to interact with the user when you with to deliver local and remote notifications are delivered to the user's device.

    Inheritance
    object
    AuthorizationRequest
    Implements
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Notifications.iOS
    Assembly: solution.dll
    Syntax
    public class AuthorizationRequest : IDisposable
    Remarks

    This method must be called before you attempt to schedule any local notifications. If "Request Authorization on App Launch" is enabled in "Edit -> Project Settings -> Mobile Notification Settings" this method will be called automatically when the app launches. You might call this method again to determine the current authorizations status or retrieve the DeviceToken for Push Notifications. However the UI system prompt will not be shown if the user has already granted or denied authorization for this app.

    Examples
    using (var req = new AuthorizationRequest(AuthorizationOption.Alert | AuthorizationOption.Badge, true))
    {
        while (!req.IsFinished)
        {
            yield return null;
        };
    
        string result = "\n RequestAuthorization: \n";
        result += "\n finished: " + req.IsFinished;
        result += "\n granted :  " + req.Granted;
        result += "\n error:  " + req.Error;
        result += "\n deviceToken:  " + req.DeviceToken;
        Debug.Log(res);
    }

    Constructors

    AuthorizationRequest(AuthorizationOption, bool)

    Initiate an authorization request.

    Declaration
    public AuthorizationRequest(AuthorizationOption authorizationOption, bool registerForRemoteNotifications)
    Parameters
    Type Name Description
    AuthorizationOption authorizationOption

    The authorization options your app is requesting. You may specify multiple options to request authorization for. Request only the authorization options that you plan to use.

    bool registerForRemoteNotifications

    Set this to true to initiate the registration process with Apple Push Notification service after the user has granted authorization If registration succeeds the DeviceToken will be returned. You should pass this token along to the server you use to generate remote notifications for the device.

    Properties

    DeviceToken

    A globally unique token that identifies this device to Apple Push Notification Network. Send this token to the server that you use to generate remote notifications. Your server must pass this token unmodified back to APNs when sending those remote notifications. This property will be empty if you set the registerForRemoteNotifications parameter to false when creating the Authorization request or if the app fails registration with the APN.

    Declaration
    public string DeviceToken { get; }
    Property Value
    Type Description
    string

    Error

    Contains error information of the request failed for some reason or an empty string if no error occurred.

    Declaration
    public string Error { get; }
    Property Value
    Type Description
    string

    Granted

    A property indicating whether authorization was granted. The value of this parameter is set to true when authorization was granted for one or more options. The value is set to false when authorization is denied for all options.

    Declaration
    public bool Granted { get; }
    Property Value
    Type Description
    bool

    IsFinished

    Indicates whether the authorization request has completed.

    Declaration
    public bool IsFinished { get; }
    Property Value
    Type Description
    bool

    RegisteredForRemoteNotifications

    Whether the app is currently registered for remote notifications.

    Declaration
    public static bool RegisteredForRemoteNotifications { get; }
    Property Value
    Type Description
    bool

    Methods

    Dispose()

    Dispose to unregister the OnAuthorizationRequestCompleted callback.

    Declaration
    public void Dispose()

    UnregisterForRemoteNotifications()

    Unregister for remote notifications. This is rarely needed, typically when user logs out. The app can always re-register.

    Declaration
    public static void UnregisterForRemoteNotifications()

    Implements

    IDisposable
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)