Esempio n. 1
0
        /// <summary>
        /// Used to request permission to send notifications to the user.
        /// Any tags set can later be used for targetting when sending notificatons.
        /// </summary>
        /// <param name="tags">Tags used for targetting.</param>
        /// <param name="callback">Callback returning the permission status.</param>
        public static void RequestPermission(
            KeyValueList tags,
            PermissionStatusCallback callback)
        {
            var    wrapper = new PermissionCBWrapper(callback);
            IntPtr tagsPtr = IntPtr.Zero;

            try
            {
                tagsPtr = tags.BinaryPtr;
                if (tagsPtr == IntPtr.Zero)
                {
                    callback(Result.InvalidArguments, false);
                    return;
                }

                trail_ntk_request_permission(
                    SDK.Raw,
                    tagsPtr,
                    tags.Count,
                    Marshal.GetFunctionPointerForDelegate(
                        new PermissionCB(NotificationsKit.onPermissionCB)
                        ),
                    GCHandle.ToIntPtr(GCHandle.Alloc(wrapper))
                    );
            }
            finally { Marshal.FreeHGlobal(tagsPtr); }
        }
Esempio n. 2
0
        /// <summary>
        /// Used to check if the game has permission to send notifications to the user.
        /// </summary>
        /// <param name="callback">Callback returning the permission status.</param>
        public static void GetPermissionStatus(PermissionStatusCallback callback)
        {
            var wrapper = new PermissionCBWrapper(callback);

            trail_ntk_get_permission_status(
                SDK.Raw,
                Marshal.GetFunctionPointerForDelegate(
                    new PermissionCB(NotificationsKit.onPermissionCB)
                    ),
                GCHandle.ToIntPtr(GCHandle.Alloc(wrapper))
                );
        }