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); }
internal static void RegisterOnActionResponder(string actionName, ActionContext.ActionResponder responder) { if (string.IsNullOrEmpty(actionName) || responder == null) { return; } if (!onActionResponders.ContainsKey(actionName)) { onActionResponders[actionName] = new List <ActionContext.ActionResponder>(); } onActionResponders[actionName].Add(responder); }
public override void OnAction(string actionName, ActionContext.ActionResponder handler) { if (string.IsNullOrEmpty(actionName) || handler == null) { return; } if (!OnActionRespondersDictionary.ContainsKey(actionName)) { OnActionRespondersDictionary[actionName] = new List <ActionContext.ActionResponder>(); } OnActionRespondersDictionary[actionName].Add(handler); lp_onAction(actionName); }
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); }
public static void DefineAction(string name, Constants.ActionKind kind, ActionArgs args, IDictionary <string, object> options, ActionContext.ActionResponder responder) { LeanplumFactory.SDK.DefineAction(name, kind, args, options, responder); }
public override void DefineAction(string name, Constants.ActionKind kind, ActionArgs args, IDictionary <string, object> options, ActionContext.ActionResponder responder) { if (name == null) { return; } if (responder != null) { ActionRespondersDictionary.Add(name, responder); } string argString = args == null ? null : args.ToJSON(); string optionString = options == null ? null : Json.Serialize(options); lp_defineAction(name, (int)kind, argString, optionString); }
public override void DefineAction(string name, Constants.ActionKind kind, ActionArgs args, IDictionary <string, object> options, ActionContext.ActionResponder responder) { if (string.IsNullOrWhiteSpace(name)) { CompatibilityLayer.LogError($"Empty name parameter."); return; } if (args == null) { CompatibilityLayer.LogError($"Args cannot be null."); return; } var ad = new ActionDefinition(); ad.Name = name; ad.Kind = kind; ad.Args = args; ad.Options = options; if (responder != null) { ad.Responder += responder; } VarCache.RegisterActionDefinition(ad); }
public abstract void OnAction(string actionName, ActionContext.ActionResponder handler);
public abstract void DefineAction(string name, Constants.ActionKind kind, ActionArgs args, IDictionary <string, object> options, ActionContext.ActionResponder responder);
public static void OnAction(string actionName, ActionContext.ActionResponder handler) { LeanplumFactory.SDK.OnAction(actionName, handler); }