示例#1
0
    void SendMessage()
    {
        mWaiting.SetActive(true);

        PublishOptions publishOptions = new PublishOptions();
        if (mForceNotify == true)
        {
          publishOptions.AddHeader(PublishOptions.ANDROID_TICKER_TEXT_TAG, mSendMessage);
          publishOptions.AddHeader(PublishOptions.ANDROID_CONTENT_TITLE_TAG, "Backendless example");
          publishOptions.AddHeader(PublishOptions.ANDROID_CONTENT_TEXT_TAG, mSendMessage);
        }
        DeliveryOptions deliveryOptions = new DeliveryOptions();
        deliveryOptions.PushBroadcast = DeliveryOptions.ALL;

        AsyncCallback<MessageStatus> callback = new AsyncCallback<MessageStatus>(
          status =>
          {
        mIsSendMessageFinish = true;
        mIsSendMessageSuccess = true;
          },
          fault =>
          {
        mResultMessage = "Error\n\nCode = " + fault.FaultCode + "\nMessage = " + fault.Message;
        mIsSendMessageFinish = true;
        mIsSendMessageSuccess = false;
          });

        Backendless.Messaging.Publish(mSendMessage, publishOptions, deliveryOptions, callback);
    }
示例#2
0
 public void cancelScheduleMessageWithWasPublishedTest()
 {
     try
     {
         string channel = "testChannel";
         object message = "Test message! Hello Word!!!";
         Dictionary<string, string> dict = new Dictionary<string, string>();
         dict.Add("City", "Kiev");
         dict.Add("Temp", "22");
         PublishOptions option = new PublishOptions
         {
             PublisherId = "testPublisher",
             Headers = dict
         };
         DeliveryOptions delivery = new DeliveryOptions
         {
         };
         var m = messagingService.Publish(message, channel, option);
         var cancel = messagingService.Cancel(m.MessageId);
         Assert.IsNotNull(cancel);
     }
     catch (BackendlessException ex)
     {
         Assert.AreEqual("5040", ex.Code);
     }
 }