Search code examples
c#uwpwindows-phonesmsmessage

Execute action when SMS is received in UWP app


I would like to programmatically set the ringtone in a UWP app. However, as I read in How to programmatically get / change ringtone and alert tones, that does not seem to be possible.

I read the How to use the save ringtone task for Windows Phone 8, but this is not what I am looking for.

Is there a way to intercept the SMS received event and execute an action when an SMS is received (I do not need to read the SMS, I just want to play a custom tone when a message is received)?

I do not want to create an SMS app.


Solution

  • Is there a way to intercept the SMS received event and execute an action when an SMS is received?

    We can use SMS received background events to achieve this. For more info, please see Run new SMS received background events and SMS send and receive sample.

    However, as @Ken has mentioned, it’s important to note that these APIs and events are intended for use by device manufacturers primarily. Refer from Windows.Devices.Sms Namespace:

    Note that this functionality is only available to mobile operator apps and Windows Store app given privileged access by mobile network operators, mobile broadband adapter IHV, or OEM. For more information, see Mobile Broadband: device apps.


    If you want to change the Ringtone, I think you can try with ms-tonepicker: URI scheme.

    To change the Ringtone, we can take advantage of tone saver like in the Example: Save a local music file as a ringtone and tone saver can "Make this my current ringtone".
    enter image description here

    For more info, please see Choose and save tones using the ms-tonepicker URI scheme.