Class InviteButton

All Implemented Interfaces:
Animation, Editable, ActionListener, ActionSource<ActionEvent>, StyleListener, IconHolder, ReleasableComponent, SelectableIconHolder, TextHolder

public class InviteButton extends ShareButton

A ShareButton that mints a fresh invite on every press and shares it, so the whole invite funnel is wired with one component.

InviteButton invite = new InviteButton("Invite a friend");
invite.setCampaign("spring");
invite.setMessage("Come and try this with me");
form.add(invite);

The button owns the share result, so invite_shared is reported only when the platform confirms the user really shared. Your own setShareResultListener(ShareResultListener) still works and is still called.

See Invites for the receiving half and for how attribution reaches your analytics reports.

  • Constructor Details

    • InviteButton

      public InviteButton()
      Default constructor.
    • InviteButton

      public InviteButton(String text)

      Creates a button with the given label.

      Parameters
      • text: the button label
  • Method Details

    • setCampaign

      public void setCampaign(String campaign)

      Groups the invites this button mints under a campaign.

      Parameters
      • campaign: the campaign name
    • getCampaign

      public String getCampaign()

      The campaign, or null.

      Returns

      the campaign

    • setChannel

      public void setChannel(String channel)

      Records how the invite is being sent.

      Parameters
      • channel: the channel name
    • getChannel

      public String getChannel()

      The channel, or null.

      Returns

      the channel

    • setPayload

      public void setPayload(String payload)

      An application defined string handed to the invited device.

      Parameters
      • payload: the payload
    • getPayload

      public String getPayload()

      The payload, or null.

      Returns

      the payload

    • setMessage

      public void setMessage(String message)

      The text placed before the link in the shared message.

      Parameters
      • message: the message
    • getMessage

      public String getMessage()

      The message, or null.

      Returns

      the message

    • getInvite

      public Invite getInvite()

      The invite minted for the most recent press, or null before the first press.

      Returns

      the invite

    • setShareResultListener

      public void setShareResultListener(ShareResultListener listener)

      Listener invoked once when the underlying share sheet (native or fallback dialog) finishes. May be null to clear a prior listener.

      On platforms that cannot observe the chosen target the listener still fires with ShareResult.sharedTo(String) passing a null package name, so the app can resume its flow.

      Overrides:
      setShareResultListener in class ShareButton
    • getShareResultListener

      public ShareResultListener getShareResultListener()
      Returns the listener registered via ShareButton.setShareResultListener(ShareResultListener) or null.
      Overrides:
      getShareResultListener in class ShareButton
    • actionPerformed

      public void actionPerformed(ActionEvent evt)

      invoked when the button is pressed

      Parameters
      • evt
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class ShareButton
    • getPropertyNames

      public String[] getPropertyNames()

      A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code

      Returns

      the property names allowing mutation

      Overrides:
      getPropertyNames in class ShareButton
    • getPropertyTypes

      public Class[] getPropertyTypes()

      Matches the property names method (see that method for further details).

      Returns

      the types of the properties

      Overrides:
      getPropertyTypes in class ShareButton
    • getPropertyValue

      public Object getPropertyValue(String name)

      Returns the current value of the property name, this method is used by the GUI builder

      Parameters
      • name: the name of the property
      Returns

      the value of said property

      Overrides:
      getPropertyValue in class ShareButton
    • setPropertyValue

      public String setPropertyValue(String name, Object value)

      Sets a new value to the given property, returns an error message if failed and null if successful. Notice that some builtin properties such as "$designMode" might be sent to components to indicate application state.

      Parameters
      • name: the name of the property

      • value: new value for the property

      Returns

      error message or null

      Overrides:
      setPropertyValue in class ShareButton