Skip to main content

Name

msys.apn.apn_status_classifier — Determine whether the delivery status code represents a permanent or temporary failure

Synopsis

require('msys.apn')

msys.apn.apn_status_classifier(status);

status: numeric

Description

**Configuration Change. ** This function is available as of Momentum version 3.5.5.

Determine the delivery status of the "DLV_Response_Status" variable in the context of an Apple push notification. This function classifies the "DLV_Response_Status" variable and returns one of the following values:

  • msys.delivery.DELIVERY_SUCCESS

  • msys.delivery.DELIVERY_TEMPFAILED

  • msys.delivery.DELIVERY_PERMFAILED

The following code example converts a failed Apple push notification to an SMPP message.

require("strict")
require("msys.delivery")
require("msys.apn")
require("msys.extended.message")

local mod = {}

function mod:generic_delivery_msg_dispose(msg)
  local status = msg:context_get(msys.core.ECMESS_CTX_MESS, "DLV_Response_Status")
  if status == "" then
    return msys.delivery.DELIVERY_CONTINUE
    -- "DLV_Response_Status" varies depending upon protocol
    -- but a message is treated as ok or delivered if and
    -- only if the DLV_Response_Status does not exist.
  elseif (msys.apn.apn_status_classifier(tonumber(status))==msys.delivery.DELIVERY_PERMFAILED) or
      (msys.apn.apn_status_classifier(tonumber(status))==msys.delivery.DELIVERY_TEMPFAILED) then
    -- reset context variable for DLV_Response_Status
    msg:context_delete(msys.core.ECMESS_CTX_MESS, "DLV_Response_Status")
    return msys.delivery.DELIVERY_DONE
  else 
    print(status, " unknown disposition!\n")
  end
end

msys.registerModule("convert", mod);

See Also

Was this page helpful?