none
Can't Register a BackgroundTask for MobileOperatorNotification event

    Вопрос

  • Hello,

    I am trying to register a MobileOperatorNotificationHandler via Service metadata but it is not get registered.

    Things i've done so far:

    • Created a class inheriting IBackgroundTask, its name is MnoBackgroundTask, Inside Run method there are just a couple of lines to show a toast.
                NetworkOperatorNotificationEventDetails notifyData = (NetworkOperatorNotificationEventDetails)taskInstance.TriggerDetails;
    
                // The network account ID is stored in notifyData.NetworkAccountId.
    
                XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                stringElements.Item(0).AppendChild(toastXml.CreateTextNode(notifyData.Message));
                stringElements.Item(1).AppendChild(toastXml.CreateTextNode(notifyData.NotificationType.ToString()));
                ToastNotification notification = new ToastNotification(toastXml);
                ToastNotificationManager.CreateToastNotifier().Show(notification);

    • Modified service metadata so that it includes the class above to register as MobileOperatorNotificationHandler.After my metadata extracted i checked the SoftwareInfo.xml file and MnoBackgroundTask was there.
    <DeviceNotificationHandlers>
                <DeviceNotificationHandler EventID="MobileOperatorNotificationHandler" EventAsset="[NameSpaceOfTheClass].MnoBackgroundTask" />
    </DeviceNotificationHandlers>
    • Added a BackgroundTask decleration to appxmanifest file of the device app. 
    <Extension Category="windows.backgroundTasks" EntryPoint="[NameSpaceOfTheClass].MnoBackgroundTask">
              <BackgroundTasks>
                    <Task Type="systemEvent" />
              </BackgroundTasks>
    </Extension>

    When i launched the app and query the background tasks registered by my app. I could not see the MnoBackgroundTask in the list. 

    Also i tried manually registering using a NetworkOperatorNotificationTrigger, this time i got an exception saying "Value does not fall within the expected range.".

    Code block for registering manually:

                    var builderTwo = new BackgroundTaskBuilder();
                    builderTwo.Name = "MobileOperatorNotificationHandler";
                    builderTwo.TaskEntryPoint = "[NameSpaceOfTheClass].MnoBackgroundTask";                
                    IBackgroundTrigger mnoTrigger = new NetworkOperatorNotificationTrigger(Context.Instance.CurrentAccount.NetworkAccountId);
                    builderTwo.SetTrigger(mnoTrigger);
                    mnoListenerRegistrationResult = builderTwo.Register(); // Exception throwed on this line. 
                    mnoListenerRegistrationResult.Completed += mnoListenerRegistrationResult_Completed;

    So, am i missing something?

    Is there a way to get more info about why i cant register the task? I mean where are the logs about the process.  

    Thanks

    Mehmet

    22 апреля 2012 г. 9:16

Ответы

  • Hi Mehmet,

    The MobileOperatorNotification event can only be registered via the Service Metadata.  For an end user, the registration will happen automatically after they connect a mobile broadband device and the app is downloaded.  For a developer, you should forcefully trigger Windows to process the metadata and register the background task.  To do this, please open ‘Devices and Printers’ in the Control Panel and press F5 or right click and select 'Refresh'.  You should do this every time you deploy or install the app and after connecting a mobile broadband device.  Please follow up if this resolves the issue.

    -Frank

  • pwr00,

    Writing a background task for mobile operator notifications in C++ is supported. Similar to C#, the event asset element in metadata's ServiceInfo.xml points to the runtime class implementing the backgroundtask interface.

    The metadata parsing error you reported suggest an error in metadata unrelated to mobile operator notifications. Can you run through the instructions & troubleshooting outlined in Development guide to creating Metro style device apps for Mobile Broadband whitepaper first, and verify you're able to write an app that calls privileged mobile broadband interfaces such as getting the SubscriberId before moving to mobile operator notifications?

    -Jack

Все ответы

  • Mehmet,

    Have you looked at the background task sample?

    http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9

    Best Wishes - Eric

    24 апреля 2012 г. 19:42
  • Hi Mehmet,

    The MobileOperatorNotification event can only be registered via the Service Metadata.  For an end user, the registration will happen automatically after they connect a mobile broadband device and the app is downloaded.  For a developer, you should forcefully trigger Windows to process the metadata and register the background task.  To do this, please open ‘Devices and Printers’ in the Control Panel and press F5 or right click and select 'Refresh'.  You should do this every time you deploy or install the app and after connecting a mobile broadband device.  Please follow up if this resolves the issue.

    -Frank

  • Hello Frank,

    ı tried your suggestion and BackgroundTask seems to be registered. Actually 4 new BackgroundTasks registered and they dont have a name. I expect at least one of them to be named "MobileOperatorNotificationHandler".

    First of my new questions is "why background tasks are nameless?".

    Also i had registered another background task(Registered with trigger type SystemTriggerType.SmsReceived) to listen incoming messages it used to work, but after registration of MNO background task it stopped showing new SMS notifications, toast messages. Is there a relation between these two BackgroundTasks? MNOBackgrountTask does not show new SMS notifications neither. 

    Thanks for your help

     

  • Hi Mehmet,

    I encourage you to read the Mobile Operator Notifications whitepaper published online at http://go.microsoft.com/fwlink/?linkid=242062 first, which will should answer your questions.The mobile broadband platform in Windows 8 provides enhanced functionality available only to a mobile network operator’s Metro style device app for receiving and displaying incoming SMS and network-initiated USSD administrative messages. These messages can be intended for user notification, such as approaching data usage cap, international roaming, or low balance, or to trigger a response from the operator’s app. The mobile broadband SMS platform filters incoming mobile broadband SMS messages into one of two types: administrative SMS notifications from the mobile network operator (MNO) and general SMS messages. Administrative SMS notifications received from a mobile network operator are only accessible to the mobile operator app and are hidden from other SMS client apps.

    Thanks,
    Jack

  • Hi!

    I have tried to register MobileOperatorNotificationHandler in the metadatapackage for quite some time now. When for example adding Event ID: MobileOperatorNotificationHandler and Event Asset: background.js, the logging from the
    parsing of the metadatapackage shows errors in the end saying "MbaeParserTask did not complete successfully. Error is 0x80070306: One or more errors occured while processing the request."

    What I actaully want to do is to register a c++ implementation of the BackgroundTask. I have made this implementation by using the example code provided by Microsoft at
    http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9

    I also have tested to register the background tasks as "normal" systemevent and the background task works.
    So there must be somthing I'm doing wrong when trying to register the operator notficiation with the metadatapackage.


    The whitepapaer you're refering to is only giving examples of how to add the notifications for js and cs. But since I still get parsing error when trying to add exactly the same values given in the white paper I suspect that
    there is something else that I need to do in order to get this to work.

    Since the white paper only gives examples on how to register js and cs, isn't it possible to call a background task implemented in c++?

    Is there some other logging I can do to see if the metadatapackage has succeeded to register the notification? Or to see what the errors in the log file actually are caused by?

    Thanks

    pwr00

  • pwr00,

    Writing a background task for mobile operator notifications in C++ is supported. Similar to C#, the event asset element in metadata's ServiceInfo.xml points to the runtime class implementing the backgroundtask interface.

    The metadata parsing error you reported suggest an error in metadata unrelated to mobile operator notifications. Can you run through the instructions & troubleshooting outlined in Development guide to creating Metro style device apps for Mobile Broadband whitepaper first, and verify you're able to write an app that calls privileged mobile broadband interfaces such as getting the SubscriberId before moving to mobile operator notifications?

    -Jack

  • Hi!

    My app is able to call the privileged mobile broadband interfaces such as calling connect on the Mbn interface and getting the network account ids from WinRT. I also get the registry values as described in your documentation.