Created
September 6, 2019 15:33
-
-
Save dhaniksahni/42747ab37fe6ae49038332d8cf2de792 to your computer and use it in GitHub Desktop.
Send WhatsApp Message using Lightning Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component controller="WhatsAppMessageService" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" > | |
<lightning:notificationsLibrary aura:id="notifLib"/> | |
<div class="row"> | |
<lightning:input aura:id="mobileNumber" name="mobileNumber" label="Mobile Number" /> | |
<lightning:input aura:id="message" name="message" label="Message" /> | |
</div> | |
<div class="row"> | |
<lightning:button variant="brand" label="Send Message" title="Send Message" onclick="{! c.handleClick }" /> | |
</div> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleClick : function(component, event, helper) { | |
helper.sendMessage(component, event); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
sendMessage : function(component, event) { | |
var isSigned = false; | |
var action = component.get("c.sendMessage"); | |
action.setParams({ | |
mobileno: component.find("mobileNumber").get("v.value"), | |
message: component.find("message").get("v.value") | |
}); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (state === "SUCCESS") { | |
component.find('notifLib').showNotice({ | |
"variant": "info", | |
"header": "Success!", | |
"message": "WhatsApp Message Sent" | |
}); | |
} else { | |
component.find('notifLib').showNotice({ | |
"variant": "error", | |
"header": "Something has gone wrong!", | |
"message": "Unfortunately, there was a problem while sending WhatsApp Message" | |
}); | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment