Whatever message this page gives is out now! Go check it out!
snsObject= getCloudService("snsCred", "snsConf")component
{
this.name="AWS_STD_Queue";
void function onApplicationStart(){
application.awsCred = {
"alias" : "aws_std_queue",
"vendorName" : "AWS",
"region" : "us-east-1",
"secretAccessKey" : "xxxxxxxxxxxxxxxxx",
"accessKeyId" : "xxxxxxxxxxxxxxxx"
}
application.snsConf = {
"serviceName" : "SNS"
}
application.sqsConf ={
"serviceName" : "SQS"
}
}
}snsObject = getCloudService(application.awsCred, application.snsConf)<cfscript>
// define the credential and the configuration aliases in the ColdFusion Admin
sns=cloudService("awsCred","snsConf")
// code below.
...........
</cfscript><cfscript>
// Using credential alias and struct for service config
snsConf = {
"alias":"snsConf",
"serviceName" : "SNS",
"clientOverrideConfig":{
"retryPolicy":{
"numRetries":4
}
},
"httpClientConfig":{
"maxConnections":50
}
}
sns= cloudService("snsCred", snsConf)
// code below
.....................
</cfscript><cfscript>
// Using config alias and struct for service credentials
// sns credentials
snsCreds={
"vendorName":"AWS",
"alias": "snsCred",
"region":"us-east-2",
"accessKeyId": "access key",
"secretAccessKey": "secret access"
}
sns= cloudService(snsCreds, "snsConf")
// code below
.....................................
</cfscript><cfscript>
// Using Structs for both cloud credential and config
snsCred={
"vendorName":"AWS",
"alias": "sns_cred_alias",
"region":"us-east-2",
"accessKeyId": "access key",
"secretAccessKey": "secret access key"
}
snsConf = {
"alias":"sns_conf_alias",
"serviceName" : "SNS",
"clientOverrideConfig":{
"retryPolicy":{
"numRetries":4
}
},
"httpClientConfig":{
"maxConnections":50
}
}
sns = cloudService(snsCred, snsConf )
// code below
...................................................................
</cfscript><cfscript>
// Create an object of administrator component and call the login method
adminObj = createObject("component","cfide.adminapi.administrator")
adminObj.login("admin")
// Create an object of cloud component
cloudObj = createObject("component","cfide.adminapi.cloud")
// define credentials struct
credentialStruct={
"alias" : "CredSNS",
"vendorName" : "AWS",
"region" : "us-east-2",
"secretAccessKey" : "secret access key",
"accessKeyId" : "access key"
}
// add credential credentialStruct
try{
cloudObj.addCredential(credentialStruct)
writeOutput("Credentials added successfully")
}
catch(any e){
writeDump(e)
}
</cfscript><cfscript>
// Create an object of administrator component and call the login method
adminObj = createObject("component","cfide.adminapi.administrator")
adminObj.login("admin")
// Create an object of cloud component
cloudObj = createObject("component","cfide.adminapi.cloud")
// define configuration struct
configStruct={
"alias":"ConfSNS",
"serviceName":"SNS",
"clientOverrideConfig":{
"retryPolicy":{
"numRetries":4
}
},
"httpClientConfig":{
"maxConnections":50
}
}
// add config configStruct
try{
cloudObj.addServiceConfig(configStruct)
writeOutput("Configuration service added successfully")
}
catch(any e){
writeDump(e)
}
</cfscript>SNSClient APIs | SNSTopic APIs | SNSSubscription APIs |
|
|
|
createTopic(topicName, topicAttributes)Parameter | Description | Type | Required |
topicName | The name of the topic to be created. | String | Yes |
topicAttributes | Key-value pairs of the following:
The following attribute applies only to server-side-encryption:
| Struct | No |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// define topic attributes
createTopicMetadata = {
"tags" = [
{"key" = "key1","value" = "value1"},
{"key" = "key2","value" = "value2"}
],
"attributes" = {
"DisplayName" = "This is a sample display name."
}
}
try{
topicResponse = sns.createTopic("NewTopic",createTopicMetadata)
writeOutput("Successfully created an SNS topic")
writeDump(topicResponse)
}
catch(any e){
writeDump(e)
}
</cfscript><cfscript>
sns = getCloudService(application.awsCred, application.snsConf);
// create the topic
myTopic = sns.createTopic("TopicSSE")
// set SSE metadata
setTopicAttribsMetadata = {
"attributeName" = "KmsMasterKeyId",
"attributeValue" = "arn:aws:kms:us-east-1:xxxxxxxx:key/xxxxxxxxxxx"
}
// set the SSE attributes to the topic
setTopicAttribsResponse=myTopic.setAttributes(setTopicAttribsMetadata)
writeDump(setTopicAttribsResponse)
</cfscript>getTopicArn()<cfscript>
sns = getCloudService(application.awsCred, application.snsConf);
// create the topic
myTopic = sns.createTopic("TopicARN")
myArn=myTopic.getTopicArn()
writeOutput("The ARN of the topic is: " & myArn)
</cfscript>deleteTopic(topicArn)Parameter | Description | Type | Required |
topicArn | The ARN of the topic that you want to delete. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("DeleteTopic")
// get topic ARN
topicArn = topic.getTopicArn()
try{
// delete topic
deleteTopicResponse = sns.deleteTopic(topicArn)
writeOutput("Topic deleted successfully")
writeDump(deleteTopicResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>listTopics(nextToken)Parameter | Description | Type | Required |
nextToken | The token returned by the previous ListTopics call. | String | No |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf);
// list all topics
topicObj = snsObj.listTopics();
writeDump(topicObj)
// get nextToken
nextTokenVal = topicObj.nextToken;
// list all topics with nextToken
listNextTopicObj = snsObj.listTopics(nextTokenVal)
writeDump(listNextTopicObj)
</cfscript>setTopicAttributes(topicAttributes)Parameter | Description | Type | Required |
topicAttributes | Key-value pairs of the following:
The following attribute applies only to server-side-encryption:
| Struct | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// define topic attributes
createTopicMetadata = {
"tags" = [
{"key" = "key1","value" = "value1"},
{"key" = "key2","value" = "value2"}
],
"attributes" = {
"DisplayName" = "This is a sample display name."
}
}
// create topic
topicObj=sns.createTopic("NewTopic",createTopicMetadata)
// get topic Arn
topicArn = topicObj.getTopicArn()
// metadata for set attributes
setTopicAttribsMetadata = {
"topicArn"= topicArn,
"attributeName" = "DisplayName",
"attributeValue" = "value"
}
try{
setTopicAttrResponse = sns.setTopicAttributes(setTopicAttribsMetadata)
writeOutput("Topic attributes set successfully")
writeDump(setTopicAttrResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>getTopicAttributes(topicARN)Parameter | Description | Type | Required |
topicArn | The ARN of the topic, whose attributes you want to retrieve. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// define topic attributes
createTopicMetadata = {
"tags" = [
{"key" = "key1","value" = "value1"},
{"key" = "key2","value" = "value2"}
],
"attributes" = {
"DisplayName" = "This is a sample display name."
}
}
// create topic
topicObj=sns.createTopic("TopicAttributes",createTopicMetadata)
// get topic Arn
topicArn = topicObj.getTopicArn()
// metadata for set attributes
setTopicAttribsMetadata = {
"topicArn"= topicArn,
"attributeName" = "DisplayName",
"attributeValue" = "value"
}
// set topic attributes
sns.setTopicAttributes(setTopicAttribsMetadata)
// get topic attributes
getTopicAttributeResponse=sns.getTopicAttributes(topicArn)
writeDump(getTopicAttributeResponse)
</cfscript>tagTopic(topicArn,tags)Parameter | Description | Type | Required |
topicArn | The ARN of the topic, which you want to add tags. | String | Yes |
tags | The list of tags to add to the topic. | Struct | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("TagTopic")
// get topic ARN
topicArn= topic.getTopicArn()
// set tag metadata
tagTopicMetadata = {
"tags" = [
{"key" = "Team","value" = "Development"},
{"key" = "Environment","value" = "Production"}
]
}
// tag the topic
try{
tagTopicResponse = sns.tagTopic(topicArn,tagTopicMetadata)
writeOutput("Topic has been tagged successfully")
writeDump(tagTopicResponse)
}
catch (any e){
writeDump(e)
}
</cfscript>listTopicTags(topicArn)Parameter | Description | Type | Required |
topicArn | The ARN of the topic whose tags you want to list. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("UntagTopic")
// get topic ARN
topicArn=topic.getTopicArn()
// tag metadata
tagTopicMetadata = {
"tags" = [
{"key" = "Team","value" = "Development"},
{"key" = "Environment","value" = "Production"}
]
}
// tag topic
sns.tagTopic(topicArn,tagTopicMetadata)
// list topic tags
res=sns.listTopicTags(topicArn)
writeOutput("The list of tags are:")
writeDump(res.tags)
</cfscript>untagTopic(topicArn,tags)Parameter | Description | Type | Required |
topicArn | The ARN of the topic, from which you want to remove tags. | String | Yes |
tags | The list of tag keys to remove from the specified topic. | Array | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("UntagTopic")
// get topic ARN
topicArn=topic.getTopicArn()
// tag metadata
tagTopicMetadata = {
"tags" = [
{"key" = "Team","value" = "Development"},
{"key" = "Environment","value" = "Production"}
]
}
// tag topic
sns.tagTopic(topicArn,tagTopicMetadata)
// untag metadata
untagTopicMetadata = {
"tagKeys" = ["Team"]
}
try{
res = sns.untagTopic(topicArn,untagTopicMetadata)
writeOutput("Topic untagged successfully" & "<br/>")
writeOutput("Tags left after untagging are:")
writeDump(topic.listTags().tags)
}
catch(any e){
writeDump(e)
}
</cfscript>subscribe(subscription)Parameter | Description | Type | Required |
subscription | Attributes map Key-value pairs of the following:
Endpoints The following endpoints are supported:
Protocol The following protocols are supported:
ReturnSubscriptionArn: When TRUE, returns the subscription ARN with the subscription request. TopicARN: The ARN of the topic you want to subscribe to. | Struct | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
topic = sns.createTopic("SMSSubscription");
subscribeMetadata = {
"topicArn" = topic.getTopicArn(),
"endpoint" = "<your phone number>",
"protocol" = "sms"
}
try{
subscription= topic.subscribe(subscribeMetadata)
writeOutput("Subscribed to the topic successfully")
writeDump(subscription)
}
catch (any e){
writeDump(e)
}
</cfscript><cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
topic = sns.createTopic("EmailSubscription");
subscribeMetadata = {
"topicArn" = topic.getTopicArn(),
"endpoint" = "johndoe@email.com",
"protocol" = "email"
}
try{
subscription= topic.subscribe(subscribeMetadata)
writeOutput("Subscribed to the topic successfully")
writeDump(subscription)
}
catch (any e){
writeDump(e)
}
</cfscript><cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
topic = sns.createTopic("EmailSubscription");
subscribeMetadata = {
"topicArn" = topic.getTopicArn(),
"endpoint" = "https://coldfusion.adobe.com/",
"protocol" = "https"
}
try{
subscription= topic.subscribe(subscribeMetadata)
writeOutput("Subscribed to the topic successfully")
writeDump(subscription)
}
catch (any e){
writeDump(e)
}
</cfscript>confirmSubscription(topicArn, subscription)Parameter | Description | Type | Required |
AuthenticateOnUnsubscribe | Indicates whether unsubscription to a subscription requires authentication. | String | No |
Token | The token sent to an endpoint. | String | Yes |
TopicArn | The ARN of the topic for which you wish to confirm a subscription. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
topicObj = snsObj.createTopic("confirmSubscription");
topicARN = topicObj.getTopicArn();
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@example.com",
"protocol" = "email"
}
// manually fetch token value from email
tokenVal = "token value";
metadata = {
"token" = tokenVal
}
try{
confirmationObj = snsObj.confirmSubscription(topicARN,metadata)
writeOutput("Subscription confirmed successfully")
writeoutput(confirmationObj.subscriptionArn)
}
catch(any e){
writeDump(e)
}
</cfscript>unsubscribe(subscriptionArn)Parameter | Description | Type | Required |
subscriptionArn | The ARN of the subscription to be deleted. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create the topic
topic = sns.createTopic("UnsubTopic")
// subscription metadata
subscribeMetadata = {
"topicArn" = topic.getTopicArn(),
"endpoint" = "johndoe@email.com",
"protocol" = "email"
}
// subscribe to the topic
subscription = topic.subscribe(subscribeMetadata)
// get subscription Arn
//subscriptionArn = subscription.getSubscriptionArn()
// After confirming subscription, you get a subscription Arn
subscriptionArn="arn:aws:sns:us-east-1:534385124010:UnsubTopic:6b35449d-90e7-4e63-aaf6-990da9cd1a51"
try{
unsubResponse= sns.unsubscribe(subscriptionArn)
writeOutput("Unsubscribed from topic successfully")
writeDump(unsubResponse)
}
catch(any e){
writeDump(e)
}
</cfscript>listTopicSubscriptions(topicArn)
listTopicSubscriptions(String topicArn, String nextToken)Parameter | Description | Type | Required |
topicArn | The Arn of the topic from which you want to unsubscribe. | String | Yes |
nextToken | The token returned by the previous call. | String | No |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create the topic
topic = sns.createTopic("EmailSubscription")
// get topic ARN
topicARN = topic.getTopicArn()
// set subscription metadata
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@example.com",
"protocol" = "email"
}
// subscribe to the topic
subscription= topic.subscribe(subscribeMetadata)
// get the subscriptions
resp=sns.listTopicSubscriptions(topicARN)
writeOutput("List of subscriptions:")
writeDump(resp.subscriptions)
</cfscript>listSubscriptions(nextToken)Parameter | Description | Type | Required |
nextToken | The token returned by the previous ListSubscriptions call. | String | No |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
// create the topic
topicObj = snsObj.createTopic("ListSubs")
// get topic ARN
topicARN = topicObj.getTopicArn()
// set subscription metadata
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = application.emailId,
"protocol" = "email"
}
// subscribe to the topic
topicObj.subscribe(subscribeMetadata)
// list subscriptions without nextToken parameter
subsObj = snsObj.listSubscriptions()
// get nextToken
nextToken=subsObj.nextToken
// list subscriptions with nextToken parameter
ntObj=snsObj.listSubscriptions(nextToken)
writeDump(ntObj)
</cfscript>setSubscriptionAttributes(subscriptionAttributes)Parameter | Description | Type | Required |
subscriptionAttributes |
| Struct | Yes |
attributeValue | The new value for the attribute in JSON format. | String | No |
subscriptionArn | The ARN of the subscription to modify. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
topic = sns.createTopic("SubscriptionAttrib")
// get topic ARN
topicARN = topic.getTopicArn()
// set subscription metadata
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@email.com",
"protocol" = "email"
}
// subscribe to the topic
subscription= topic.subscribe(subscribeMetadata)
// get the subscription ARN
// subsARN = subscription.getSubscriptionArn()
// After confirming subscription, you get a subscription Arn
subsARN="arn:aws:sns:us-east-1:534385124010:SubscriptionAttrib:735e692e-b085-48a6-ac01-42a1211bf86d"
// set filter policy
filterPolicy = {
"OrderType" = ["Retail"]
}
// set subscription attribute metadata
setSubscribeMetadata = {
"attributeName" = "FilterPolicy",
"attributeValue" = serializeJson(filterPolicy),
"subscriptionArn"=subsARN
}
try{
setSubsObj = sns.setSubscriptionAttributes(setSubscribeMetadata)
writeOutput("Attributes have been set successfully")
writeDump(setSubsObj)
}
catch(any e){
writeDump(e)
}
</cfscript>getSubscriptionAttributes(subscriptionArn)Parameter | Description | Type | Required |
subscriptionArn | The ARN of the subscription whose properties you want to return. | String | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
topic = sns.createTopic("GetSubscriptionAttrib")
// get topic ARN
topicARN = topic.getTopicArn()
// set subscription metadata
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@example.com",
"protocol" = "email"
}
// subscribe to the topic
subscription= topic.subscribe(subscribeMetadata)
// get the subscription ARN
// subsARN = subscription.getSubscriptionArn()
// After confirming subscription, you get a subscription Arn
subsARN="arn:aws:sns:us-east-1:534385124010:GetSubscriptionAttrib:482d04e0-f5d6-4f4e-b6f9-9f721212a5c4"
// set filter policy
filterPolicy = {
"OrderType" = ["Retail"]
}
// set subscription attribute metadata
setSubscribeMetadata = {
"attributeName" = "FilterPolicy",
"attributeValue" = serializeJson(filterPolicy),
"subscriptionArn"=subsARN
}
// set subscription attributes
sns.setSubscriptionAttributes(setSubscribeMetadata)
// get subscription attributes
getSubsObj = sns.getSubscriptionAttributes(subsARN)
writeOutput("The attributes are:")
writeDump(getSubsObj.attributes)
</cfscript>publish(Struct message)Parameter | Description | Type | Required |
message | The message you want to send. SMS messages
JSON messages
| String | Yes |
messageAttributes | Message attributes for Publish action. For more information, see Message attribute values. | Struct | No |
messageStructure | Set MessageStructure to json if you want to send a different message for each protocol. Valid value is json. | String | No |
phoneNumber | The phone number to which you want to deliver an SMS message. | String | No |
subject | The subject line of the message. | String | No |
topicArn | The topic you want to publish to. | String | No |
{
"student":
[
{
"id":"01",
"name": "Tom",
"lastname": "Price"
},
{
"id":"02",
"name": "Nick",
"lastname": "Thameson"
}
],
"default" : "sample default JSON message"
}<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("PubMessageJSON")
// get topic Arn
topicARN = topic.getTopicArn()
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@example.com",
"protocol" = "email"
}
subscriptionObj = topic.subscribe(subscribeMetadata);
studentFile = fileRead(expandPath('student.json'));
// "messageStructure" = "json" is defined then only default msg will be published
publishMetadata = {
"messageBody" = studentFile,
"messageStructure" = "json"
}
try{
publishResponse = topic.publish(publishMetadata)
writeOutput("Message published successfully")
writeDump(publishResponse)
}
catch(any e){
writeOutput("Failed to publish message")
writeDump(e)
}
</cfscript><cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("PubMessageSMS")
// get topic Arn
topicARN = topic.getTopicArn()
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "<your phone number>",
"protocol" = "sms"
}
subscriptionObj = topic.subscribe(subscribeMetadata);
studentFile = fileRead(expandPath('student.json'));
// "messageStructure" = "json" is defined then only default msg will be published
publishMetadata = {
"messageBody" = studentFile,
"messageStructure" = "json"
}
try{
publishResponse = topic.publish(publishMetadata)
writeOutput("Message published successfully")
writeDump(publishResponse)
}
catch(any e){
writeOutput("Failed to publish message")
writeDump(e)
}
</cfscript><cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// create a topic
topic = sns.createTopic("PubMessageEmail")
// get topic Arn
topicARN = topic.getTopicArn()
// set subscribe metadata
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = "john@email.com",
"protocol" = "email"
}
subscriptionObj = topic.subscribe(subscribeMetadata)
// publish metadata
publishMetadata = {
"messageBody" = "Publish Email message from John",
"messageStructure" = "String",
"Subject"= "Subscription Notification"
}
try{
publishResponse = topic.publish(publishMetadata)
writeOutput("Message published sucessfully")
writeDump(publishResponse)
}
catch(any e){
writeOutput("Failed to publish message")
writeDump(e)
}
</cfscript>setSMSAttributes(smsAttributes)Parameter | Description | Type | Required |
smsAttributes | Key-value pair of the following:
| Struct | Yes |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
smsAttributes ={ "
attributes":{
"DeliveryStatusIAMRole":"",
"DeliveryStatusSuccessSamplingRate":"",
"DefaultSenderID":"",
"DefaultSMSType":"Transactional",
"UsageReportS3Bucket":"",
"MonthlySpendLimit":2
}
}
res =sns.setSMSAttributes(smsAttributes)
writeDump(res)
</cfscript>getSMSAttributes(attribute)Parameter | Description | Type | Required |
attribute | Attribute that you'd set in setSMSAttributes, for which you want to get the value. | Array of string | No |
<cfscript>
sns = getCloudService(application.awsCred, application.snsConf)
// get the SMS attributes
response=sns.getSMSAttributes()
writeDump(response)
writeoutput(response.attributes.DefaultSMSType)
</cfscript>addPermission(String topicArn, Struct permission)Parameter | Description | Type | Required |
label | Unique Id for the policy. | String | Yes |
actions | The actions that users can execute. | Array of strings | Yes |
awsaccountIds | The AWS account IDs of the users who will be granted access to the specified actions. | Array of strings | Yes |
topicArn | The ARN of the topic whose access control policy you wish to modify. | String | Yes |
<cfscript>
snsObj = cloudService(application.awsCred, application.snsConf)
// create a topic
topicObj = snsObj.createTopic("AddPermission")
// Add permission struct
addPermissionAttribute = {
"label" : "NewPermission",
"actions": ["Publish"],
"awsaccountIds": ["xxxxxxxxxxxx"]
};
res = snsObj.addPermission(topicArn,addPermissionAttribute)
writeDump(res)
writeoutput(res.sdkHttpResponse.statusCode)
</cfscript>removePermission(String topicArn, String permissionLabel)Parameter | Description | Type | Required |
permissionLabel | Unique Id of the statement to be removed. | String | Yes |
topicArn | The ARN of the topic whose access control policy that you want to remove. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
// topic arn
topicArn="arn:aws:sns:us-east-1:xxxxxxxxxxx:AddPermission"
label = "NewPermission"
try{
res = snsObj.removePermission(topicArn,label)
writeOutput("Permission removed successfully")
writeDump(res)
}
catch(any e){
writeDump(e)
}
</cfscript>createPlatformApplication(Struct platformApplication)Parameter | Decription | Type | Required |
attributes | Struct containing the following keys:
For more information, see Platform application attributes. | Struct | Yes |
name | The name of the application. | String | Yes |
platform | The following platforms are supported:
| String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
platformMetadata ={
"attributes" : {
"PlatformCredential": application.GCMServerKey,
"PlatformPrincipal":""
},
"name" : "CFgcmpushapp",
"platform" : "GCM"
}
resp = snsObj.createPlatformApplication(platformMetadata);
writeDump(resp)
writeoutput(resp.platformApplicationArn)
</cfscript>deletePlatformApplication(platformApplicationArn)Parameter | Description | Type | Required |
PlatformApplicationArn | PlatformApplicationArn of platform application object to delete. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
// create the platform application
platformMetadata ={
"attributes" : {
"PlatformCredential": application.GCMServerKey,
"PlatformPrincipal":""
},
"name" : "PushAppForCF",
"platform" : "GCM"
}
resp = snsObj.createPlatformApplication(platformMetadata)
// get the platform ARN
platformArn=resp.platformApplicationArn
// delete the platform application
try{
deletePltAppRes = snsObj.deletePlatformApplication(platformArn)
writeOutput("Platform application deleted successfully")
writeDump(deletePltAppRes)
}
catch(any e){
writeDump(e)
}
</cfscript>createPlatformEndpoint(Struct platformEndpoint)Parameter | Description | Type | Required |
attributes | Key-value pair of the following:
For more information, see endpoint attributes. | Struct | Yes |
PlatformApplicationArn | The platform application ARN obtained from a CreatePlatformApplication call. | String | Yes |
Token | Unique identifier created by the notification service for an app on a device. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
// platform endpoint struct
platformMetadata ={
"PlatformApplicationArn" : application.PlatformApplicationArn,
"Token" : application.FCMToken
}
createResp = snsObj.createPlatformEndpoint(platformMetadata)
writeDump(createResp)
</cfscript>deleteEndpoint(endpointArn)Parameter | Description | Type | Required |
endpointArn | EndpointArn of endpoint to delete. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf)
// platform endpoint struct
platformMetadata ={
"PlatformApplicationArn" : application.PlatformApplicationArn,
"Token" : application.FCMToken
}
createResp = snsObj.createPlatformEndpoint(platformMetadata)
// get endpoint arn
endpointArn = createResp.endpointArn;
try{
deleteResp= snsObj.deleteEndpoint(endpointArn)
writeOutput("Endpoint deleted successfully")
writeDump(deleteResp)
}
catch(any e){
writeDump(e)
}
</cfscript>getEndpointAttributes(endpointArn)Parameter | Description | Type | Required |
endpointArn | Endpoint ARN to get the attributes of. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf);
platformMetadata ={
"PlatformApplicationArn" : application.PlatformApplicationArn,
"Token" : application.FCMToken
}
createResp = snsObj.createPlatformEndpoint(platformMetadata);
endpointArn = createResp.endpointArn;
getResp = snsObj.getEndpointAttributes(endpointArn);
//writedump(getResp);
writeoutput(getResp.attributes.Enabled);
</cfscript>optInPhoneNumber(phoneNumber)Parameter | Description | Type | Required |
phoneNumber | The phone number to opt in. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf);
optInResp = snsObj.optInPhoneNumber(application.phoneNum);
writeoutput(optInResp.sdkHttpResponse.statusCode);
</cfscript>listPhoneNumbersOptedOut(nextToken)Parameter | Description | Type | Required |
nextToken | String to use when you call this function to get list of phone numbers that are available after the first page of results. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf);
phoneNumOptedOut = snsObj.listPhoneNumbersOptedOut();
writeoutput(phoneNumOptedOut.sdkHttpResponse.statusCode);
</cfscript>checkIfPhoneNumberIsOptedOut(phoneNumber)Parameter | Description | Type | Required |
phoneNumber | The phone number for which you want to check the opt out status. | String | Yes |
<cfscript>
snsObj = getCloudService(application.awsCred, application.snsConf);
topicObj = snsObj.createTopic("checkIfPhoneNumberIsOptedOut");
topicARN = topicObj.getTopicArn();
subscribeMetadata = {
"topicArn" = topicARN,
"endpoint" = application.phoneNum,
"protocol" = "sms"
};
subsResp = topicObj.subscribe(subscribeMetadata);
phoneNumOptedOut = snsObj.checkIfPhoneNumberIsOptedOut(application.phoneNum);
writeoutput(phoneNumOptedOut.isOptedOut);
</cfscript>