6.8.4 CancelNotification

CancelNotification method cancels the registration for notification of new messages. It is available only in synchronous mode.

The following is an example for using CancelNotification:


messaging_handle.call('CancelNotification',{'Type': u'NewMessage'})

The following table summarizes the specification of CancelNotification:

Interface IMessaging
Description Cancels registration for notification of new messages.
Response Model Synchronous
Pre-condition Valid instance of IMessaging interface is instantiated.
Post-condition Stop getting new message notifications.

Input Parameters

Input parameter specifies the request for canceling notification of new messages. This must contain the Notification Type, and this property must contain the value NewMessage.

Table 6.174: Input parameters for CancelNotification
Name Type Range Description
Type unicode string NewMessage Performs operation based on the specified content types.

Output Parameters

Output parameters contain ErrorCode, and ErrorMessage if the operation fails.

Table 6.175: Output parameters for CancelNotification
Name Type Range (Type: string) Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.


The following table lists the error codes and their values:

Table 6.176: Error codes
Error code value Description
0 Success
1000 Invalid service argument
1002 Bad argument type
1003 Missing argument

Error Messages

The following table lists the error messages and their description:

Table 6.177: Error messages
Error messages Description
Messaging:CancelNotification:Type Type Invalid Specifies if the type of Type parameter is invalid.
Messaging:CancelNotification:Type Value Incorrect Specifies if the value of Type parameter is incorrect.
Messaging:CancelNotification:Type Missing Specifies if the Type parameter is missing.
Messaging:CancelNotification:Asynchronous Operation not supported Specifies if CancelNotification is called asynchronously.


The following sample code illustrates how to cancel a notification:

import scriptext
import e32

lock = e32.Ao_lock()
messaging_handle = scriptext.load('Service.Messaging', 'IMessaging')

def new_sms_callback(trans_id, event_id, output_params):
    if trans_id == sms_id and event_id == scriptext.EventCompleted:
        print "SMS received from" + output_params['ReturnValue']['Sender'])
        print "Error in callback"
    # Cancel notification request
    messaging_handle.call('CancelNotification', {'Type': u'NewMessage'})

# The callback 'new_sms_callback' will be called when a sms is received
sms_id = messaging_handle.call('RegisterNotification', {'Type': u'NewMessage'},

# Send SMS to self so that the notification callback is hit
messaging_handle.call('Send', {'MessageType': u'SMS', 'To': u'12345678', 
                               'BodyText': u'Hi self'})

See About this document... for information on suggesting changes.