Example #1
0
        public void FromNativeToBridge()
        {
            var XKeys = new NSString[] { (NSString)"key" };
            var XObj  = new NSObject[] { (NSString)"value" };

            NITTrackingInfo NTrack =
                NITTrackingInfo.TrackingInfoFromRecipeId("recid",
                                                         NSDictionary <NSString, NSObject> .FromObjectsAndKeys(XObj, XKeys));

            NITFeedback NFeed = new NITFeedback();

            NFeed.Question            = "Question?";
            NFeed.NotificationMessage = "ciao";
            NFeed.RecipeId            = "rec-id";
            NFeed.TrackingInfo        = NTrack;
            XCFeedbackNotification XFeed = AdapterFeedback.GetCommonType(NFeed);

            Assert.True(XFeed.Question.Equals(NFeed.Question));
            Assert.NotNull(XFeed.TrackingInfo.extras);
            object value = XFeed.TrackingInfo.extras["key"];

            Assert.NotNull(value);
            Assert.True(value is string);
            Assert.True(XFeed.TrackingInfo.extras["key"].Equals("value"));
        }
Example #2
0
        public void SendEvent(XCEvent ev)
        {
            if (ev.GetPluginName() == XCFeedbackEvent.PluginName)
            {
                XCFeedbackEvent feedbackEvent = (XamarinBridge.PCL.Types.XCFeedbackEvent)ev;

                XCFeedbackNotification feedback       = feedbackEvent.FeedbackNotification;
                NITFeedback            nativeFeedback = new NITFeedback();

                nativeFeedback = AdapterFeedback.GetNative(feedback);

                NITFeedbackEvent nativeFeedbackEvent = new NITFeedbackEvent(nativeFeedback, feedbackEvent.rating, feedbackEvent.comment);
                NITManager.DefaultManager.SendEventWithEvent(nativeFeedbackEvent, (error) =>
                {
                    if (error != null)
                    {
                        Console.WriteLine("SendEventWithEvent error ios" + error);
                    }
                    else
                    {
                        Console.WriteLine("SendEventWithEvent ios");
                    }
                });
            }
        }
Example #3
0
            public override void GotFeedback(NITFeedback Feedback, NITTrackingInfo TrackingInfo)
            {
                XCFeedbackNotification XFeedback = AdapterFeedback.GetCommonType(Feedback);

                if (NearPCL.GetContentManager() != null)
                {
                    NearPCL.GetContentManager().GotXFeedbackNotification(XFeedback);
                }
                else
                {
                    Console.WriteLine("You receive a content but you haven't registered a content manager");
                }
            }
Example #4
0
        public static NITFeedback GetNative(XCFeedbackNotification xfeed)
        {
            NITFeedback native = new NITFeedback();

            native.TrackingInfo = NITTrackingInfo.TrackingInfoFromRecipeId(xfeed.TrackingInfo.RecipeId,
                                                                           AdapterUtils.From(xfeed.TrackingInfo.extras));

            native.NotificationMessage = xfeed.NotificationMessage;
            native.Question            = xfeed.Question;
            native.ID = xfeed.Id;

            return(native);
        }
Example #5
0
        public static XCFeedbackNotification GetCommonType(Feedback native)
        {
            XCFeedbackNotification xfeed = new XCFeedbackNotification();

            xfeed.TrackingInfo = new XCTrackingInfo();

            xfeed.NotificationMessage   = native.NotificationMessage;
            xfeed.Question              = native.Question;
            xfeed.TrackingInfo.RecipeId = native.TrackingInfo.RecipeId;
            xfeed.TrackingInfo.extras   = AdapterUtils.From(native.TrackingInfo.Metadata);
            xfeed.Id = native.Id;

            return(xfeed);
        }
Example #6
0
        public static XCFeedbackNotification GetCommonType(NITFeedback native)
        {
            XCFeedbackNotification xfeed = new XCFeedbackNotification();

            xfeed.TrackingInfo = new XCTrackingInfo();

            xfeed.NotificationMessage = native.NotificationMessage;
            xfeed.Question            = native.Question;
            // xfeed.RecipeId = native.RecipeId;
            xfeed.TrackingInfo.extras   = AdapterUtils.FromNS(native.TrackingInfo.ExtrasDictionary());
            xfeed.TrackingInfo.RecipeId = native.TrackingInfo.RecipeId;
            xfeed.Id = native.ID;

            return(xfeed);
        }
Example #7
0
        public static Feedback GetNative(XCFeedbackNotification xfeed)
        {
            Feedback     native      = new Feedback();
            TrackingInfo nativeTrack = new TrackingInfo();

            nativeTrack.RecipeId = xfeed.TrackingInfo.RecipeId;
            nativeTrack.Metadata = xfeed.TrackingInfo.extras;

            native.NotificationMessage = xfeed.NotificationMessage;
            native.Question            = xfeed.Question;
            native.RecipeId            = xfeed.RecipeId;
            native.TrackingInfo        = nativeTrack;
            native.Id = xfeed.Id;

            return(native);
        }
Example #8
0
        public void SendEvent(XCEvent ev)
        {
            if (ev.GetPluginName() == XCFeedbackEvent.PluginName)
            {
                XCFeedbackEvent feedbackEvent = (XamarinBridge.PCL.Types.XCFeedbackEvent)ev;

                XCFeedbackNotification feedback = feedbackEvent.FeedbackNotification;

                Feedback nativeFeedback = AdapterFeedback.GetNative(feedback);

                FeedbackEvent nativeFeedbackEvent = new FeedbackEvent(nativeFeedback, feedbackEvent.rating, feedbackEvent.comment);
                NearItManager.Instance.SendEvent(nativeFeedbackEvent);
            }
            else
            {
                Console.WriteLine("Error SendEvent android");
            }
        }
Example #9
0
        public void FromBridgeToNative()
        {
            XCTrackingInfo xtrack = new XCTrackingInfo();

            xtrack.RecipeId = "recid";
            xtrack.extras   = new Dictionary <string, object>();
            xtrack.extras.Add("key", "value");

            XCFeedbackNotification XFeed = new XCFeedbackNotification();

            XFeed.Question            = "Question?";
            XFeed.NotificationMessage = "ciao";
            XFeed.RecipeId            = "rec-id";
            XFeed.TrackingInfo        = xtrack;

            Feedback NFeed = AdapterFeedback.GetNative(XFeed);

            Assert.True(NFeed.Question.Equals(XFeed.Question));
        }
Example #10
0
        public void FromNativeToBridge()
        {
            TrackingInfo NTrack = new TrackingInfo();

            NTrack.RecipeId = "recid";
            NTrack.Metadata = new Dictionary <Java.Lang.String, Java.Lang.Object>();
            NTrack.Metadata.Add("key", "value");

            Feedback NFeed = new Feedback();

            NFeed.Question            = "Question?";
            NFeed.NotificationMessage = "ciao";
            NFeed.RecipeId            = "rec-id";
            NFeed.TrackingInfo        = NTrack;

            XCFeedbackNotification XFeed = AdapterFeedback.GetCommonType(NFeed);

            Assert.True(XFeed.Question.Equals(NFeed.Question));
            Assert.True(XFeed.TrackingInfo.extras["key"].Equals("value"));
        }
Example #11
0
 public void GotXFeedbackNotification(XCFeedbackNotification notification)
 {
     throw new NotImplementedException();
 }