public static void DefineGenericDefinition() { string configVars = $"{Constants.Args.GENERIC_DEFINITION_CONFIG}.vars"; ActionArgs args = new ActionArgs() .With <IDictionary <string, object> >(Constants.Args.GENERIC_DEFINITION_CONFIG, null) .With <IDictionary <string, object> >(configVars, null); ActionContext.ActionResponder responder = new ActionContext.ActionResponder((context) => { var messageConfig = context.GetObjectNamed <Dictionary <string, object> >(Constants.Args.GENERIC_DEFINITION_CONFIG); var messageVars = context.GetObjectNamed <Dictionary <string, object> >(configVars); StringBuilder builder = new StringBuilder(); NativeActionContext nativeContext = context as NativeActionContext; if (nativeContext != null && !string.IsNullOrEmpty(nativeContext.Id)) { builder.AppendLine($"Message Id: {nativeContext.Id}"); } BuildString("message", messageConfig, builder, 0); EditorUtility.DisplayDialog(context.Name, builder.ToString(), null); }); Leanplum.DefineAction(Constants.Args.GENERIC_DEFINITION_NAME, Constants.ActionKind.MESSAGE, args, null, responder); }
public static void DefineConfirm() { ActionArgs actionArgs = new ActionArgs(); actionArgs.With <string>(Constants.Args.MESSAGE, "Confirm message"); actionArgs.With <string>(Constants.Args.ACCEPT_TEXT, "Accept"); actionArgs.With <string>(Constants.Args.CANCEL_TEXT, "Cancel"); actionArgs.WithAction <object>(Constants.Args.ACCEPT_ACTION, null) .WithAction <object>(Constants.Args.CANCEL_ACTION, null); ActionContext.ActionResponder responder = new ActionContext.ActionResponder((context) => { if (EditorUtility.DisplayDialog(Constants.Args.CONFIRM_NAME, context.GetStringNamed(Constants.Args.MESSAGE), context.GetStringNamed(Constants.Args.ACCEPT_TEXT), context.GetStringNamed(Constants.Args.CANCEL_TEXT))) { context.RunTrackedActionNamed(Constants.Args.ACCEPT_ACTION); } else { context.RunActionNamed(Constants.Args.CANCEL_ACTION); } }); Leanplum.DefineAction(Constants.Args.CONFIRM_NAME, Constants.ActionKind.MESSAGE, actionArgs, null, responder); }
public static void DefineOpenURL() { ActionArgs actionArgs = new ActionArgs(); actionArgs.With <string>(Constants.Args.URL, "https://www.example.com"); ActionContext.ActionResponder responder = new ActionContext.ActionResponder((context) => { string url = context.GetStringNamed(Constants.Args.URL); if (!string.IsNullOrEmpty(url)) { Application.OpenURL(url); } }); Leanplum.DefineAction(Constants.Args.OPEN_URL, Constants.ActionKind.ACTION, actionArgs, null, responder); }