void ShowFile(string filePath, string application)
        {
            NSDictionary dictionary = new NSDictionary();

            dictionary.SetValueForKey(new NSString("kApplicationIDKey"), new NSString(application));
            dictionary.SetValueForKey(new NSString("kFilePathKey"), new NSString(filePath));

            NSNotificationCenter.DefaultCenter.PostNotificationName(
                "kShowServiceAlert", (NSObject)this);
        }
Example #2
0
        // We can send upstream messages back to GCM
        public void SendUpstreamMessage()
        {
            var msg = new NSDictionary();

            msg.SetValueForKey(new NSString("1234"), new NSString("userId"));
            msg.SetValueForKey(new NSString("hello world"), new NSString("msg"));

            var to = "659320137171" + "@gcm.googleapis.com";

            Log("Sending Message to: {0}", to);
            Service.SharedInstance.SendMessage(msg, to, (messageId++).ToString());
        }
        async Task ProcessRequestForApplication(string application, string service, string version, string method, Foundation.NSObject parameters, NSObject[] attachments, string requestID)
        {
            bool    requestProcessed = false;
            NSError goodError        = null;

            if (!ServiceController.ConsumeFrontRequestService(service, application, method, version))
            {
                if (String.Equals(service, "com.good.gd.example.services.greetings"))
                {
                    requestProcessed = ProcessGreetingsService(application, service, version, method, parameters, attachments, requestID, out goodError);
                }
                else if (String.Equals(service, "com.gd.example.services.dateandtime"))
                {
                    requestProcessed = ProcessDateAndTimeServiceRequest(application, service, version, method, parameters, attachments, requestID, out goodError);
                }

                if (!requestProcessed && goodError == null)
                {
                    NSDictionary errorDetail = new NSDictionary();
                    errorDetail.SetValueForKey(new NSString(ServiceController.kServiceNotImplementedDescription), NSError.LocalizedDescriptionKey);
                    NSError serviceError = new NSError(ICCErrorConstants.GDServicesErrorDomain, ICCErrorConstants.GDServicesErrorServiceNotFound, errorDetail);
                    ServiceController.SendErrorTo(application, serviceError);
                }
            }
        }
        public static NSDictionary ToNsDictionary(this IDictionary <string, string> dict)
        {
            var ns = new NSDictionary();

            foreach (var pair in dict)
            {
                ns.SetValueForKey(new NSString(pair.Value), new NSString(pair.Key));
            }

            return(ns);
        }
Example #5
0
 async Task ProcessRequestForApplication(string application, string service, string version, string method, Foundation.NSObject parameters, NSObject[] attachments, string requestID)
 {
     InvokeOnMainThread(() => {
         if (!ServiceController.ConsumeFrontRequestService(service, application, method, version))
         {
             NSDictionary errorDetail = new NSDictionary();
             errorDetail.SetValueForKey(new NSString(ServiceController.kServiceNotImplementedDescription), NSError.LocalizedDescriptionKey);
             NSError serviceError = new NSError(ICCErrorConstants.GDServicesErrorDomain, ICCErrorConstants.GDServicesErrorServiceNotFound, errorDetail);
             ServiceController.SendErrorTo(application, serviceError);
         }
     });
 }
Example #6
0
 public bool ConsumeFrontRequestService(string serviceID, string application, string method, string version)
 {
     if (serviceID.Equals(GoodDynamics.ICCMiscConstants.GDFrontRequestService) && version.Equals("1.0.0.0"))
     {
         if (method.Equals(GoodDynamics.ICCMiscConstants.GDFrontRequestMethod))
         {
             NSError error = null;
             GDService.BringToFront(application, out error);
         }
         else
         {
             NSDictionary errorDetail = new NSDictionary();
             errorDetail.SetValueForKey(new NSString(kMethodNotImplementedDescription), NSError.LocalizedDescriptionKey);
             NSError serviceError = new NSError(ICCErrorConstants.GDServicesErrorDomain, ICCErrorConstants.GDServicesErrorMethodNotFound, errorDetail);
             SendErrorTo(application, serviceError);
         }
         return(true);
     }
     return(false);
 }
		private (string, NSDictionary) GetImageMetadata(NSDictionary info)
		{
			string localId = null;
			NSDictionary meta = null;
			try
			{
				if (source == UIImagePickerControllerSourceType.Camera)
				{
					meta = info[UIImagePickerController.MediaMetadata] as NSDictionary;
					if (meta != null && meta.ContainsKey(ImageIO.CGImageProperties.Orientation))
					{
						var newMeta = new NSMutableDictionary();
						newMeta.SetValuesForKeysWithDictionary(meta);
						var newTiffDict = new NSMutableDictionary();
						newTiffDict.SetValuesForKeysWithDictionary(meta[ImageIO.CGImageProperties.TIFFDictionary] as NSDictionary);
						newTiffDict.SetValueForKey(meta[ImageIO.CGImageProperties.Orientation], ImageIO.CGImageProperties.TIFFOrientation);
						newMeta[ImageIO.CGImageProperties.TIFFDictionary] = newTiffDict;

						meta = newMeta;
					}
					var location = options.Location;
					if (meta != null && location != null)
					{
						meta = SetGpsLocation(meta, location);
					}
				}
				else
				{
					(meta, localId) = PhotoLibraryAccess.GetPhotoLibraryMetadata(info[UIImagePickerController.ReferenceUrl] as NSUrl);
				}
				if (options.RotateImage)
				{
					meta.SetValueForKey((NSNumber)0, ImageIO.CGImageProperties.Orientation);
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine($"Unable to get metadata: {ex}");
			}
			return (localId, meta);
		}
Example #8
0
        void ReportError(string application, string requestID, string message, int code)
        {
            var          localizedKey = NSError.LocalizedDescriptionKey;
            NSError      error        = null;
            NSDictionary userInfo     = new NSDictionary();

            userInfo.SetValueForKey(new NSString(message), localizedKey);

            NSError replyParams = new NSError(ICCErrorConstants.GDServicesErrorDomain, code, userInfo);

            bool replyResult = GDService.ReplyTo(application, replyParams, GDTForegroundOption.ENoForegroundPreference,
                                                 null, requestID, out error);

            if (!replyResult)
            {
                Console.WriteLine("ReplyTo returned false");
            }

            if (error != null)
            {
                Console.WriteLine("GDServiceReceiveFrom failed to reply: {0} {1:d} {2}",
                                  error.Domain, error.Code, error.LocalizedDescription);
            }
        }
 /// <summary>
 /// Sets the value for key.
 /// </summary>
 /// <param name="dict">Dict.</param>
 /// <param name="value">Value.</param>
 /// <param name="key">Key.</param>
 public static void SetValueForKey(this NSDictionary dict, string value, string key)
 {
     dict.SetValueForKey(new NSString(value), new NSString(key));
 }
Example #10
0
        private void sample()
        {
            /*
             * Tracking Users
             */
            WebEngage.SharedInstance().User.Login("120543");

            WebEngage.SharedInstance().User.Logout();

            // System user attributes
            WebEngage.SharedInstance().User.SetFirstName("John");
            WebEngage.SharedInstance().User.SetLastName("Doe");

            WebEngage.SharedInstance().User.SetEmail("*****@*****.**");

            WebEngage.SharedInstance().User.SetHashedEmail("144e0424883546e07dcd727057fd3b62");

            WebEngage.SharedInstance().User.SetPhone("*****@*****.**");

            WebEngage.SharedInstance().User.SetHashedPhone("e0ec043b3f9e198ec09041687e4d4e8d");

            WebEngage.SharedInstance().User.SetGender("male");

            WebEngage.SharedInstance().User.SetBirthDateString("1994-04-29");

            WebEngage.SharedInstance().User.SetCompany("Alphabet Inc.");

            WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Push, true);
            WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.InApp, true);
            WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Sms, true);
            WebEngage.SharedInstance().User.SetOptInStatusForChannel(WEGEngagementChannel.Email, true);

            NSNumber latitude  = 72.5;
            NSNumber longitude = 19.3;

            WebEngage.SharedInstance().User.SetUserLocation(latitude, longitude);

            // Custom user attributes
            WebEngage.SharedInstance().User.SetAttribute("Twitter username", "johndoe86@orig");

            NSDateComponents dateComponents = new NSDateComponents
            {
                Day   = 29,
                Month = 4,
                Year  = 2001
            };
            NSCalendar calendar = NSCalendar.CurrentCalendar;
            NSDate     date     = calendar.DateFromComponents(dateComponents);

            WebEngage.SharedInstance().User.SetAttribute("Last order date", date);

            // List of user attributes
            NSObject[] nsArray = { new NSString("xcode"), new NSString("xcode") };
            WebEngage.SharedInstance().User.SetAttribute("IDEs", nsArray);

            // Complex custom user attributes
            NSDictionary <NSString, NSObject> dict = new NSDictionary <NSString, NSObject>();

            dict.SetValueForKey(new NSString("Z-62"), new NSString("Flat"));
            dict.SetValueForKey(new NSString("Pennant Court"), new NSString("Building"));
            dict.SetValueForKey(new NSString("Penn Road"), new NSString("Locality"));
            dict.SetValueForKey(new NSString("West Midlands"), new NSString("State"));
            dict.SetValueForKey(new NSString("WV30DT"), new NSString("PIN"));
            WebEngage.SharedInstance().User.SetAttribute("Address", dict);

            // Delete single custom user attribute
            WebEngage.SharedInstance().User.DeleteAttribute("age");

            // Delete multiple custom user attributes
            NSObject[] attributesToDelete = new NSObject[] { new NSString("age"), new NSString("email") };
            WebEngage.SharedInstance().User.DeleteAttributes(attributesToDelete);


            /*
             * Tracking Events
             */
            WebEngage.SharedInstance().Analytics.TrackEventWithName("Product Viewed");

            // Tracking event with attributes
            var addedToCartAttributes = new NSDictionary("Product ID", 1337,
                                                         "Price", 39.80,
                                                         "Quantity", 1,
                                                         "Product", "Givenchy Pour Homme Cologne",
                                                         "Category", "Fragrance",
                                                         "Currency", "USD",
                                                         "Is Premium", true
                                                         );

            WebEngage.SharedInstance().Analytics.TrackEventWithName("Added to Cart", addedToCartAttributes);

            // Tracking complex events
            var detailsProduct1 = new NSDictionary("Size", "L");

            var product1 = new NSDictionary("SKU Code", "UHUH799",
                                            "Product Name", "Armani Jeans",
                                            "Price", 300.49,
                                            "Details", detailsProduct1
                                            );
            var detailsProduct2 = new NSDictionary("Size", "L");

            var product2 = new NSDictionary("SKU Code", "UHUH799",
                                            "Product Name", "Armani Jeans",
                                            "Price", 300.49,
                                            "Details", detailsProduct1
                                            );
            var deliveryAddress = new NSDictionary("City", "San Francisco",
                                                   "ZIP", "94121"
                                                   );
            var products = new NSMutableArray <NSDictionary>(product1, product2);

            var orderPlacedAttributes = new NSDictionary("Products", products,
                                                         "Delivery Address", deliveryAddress,
                                                         "Coupons Applied", new NSMutableArray <NSString>(new NSString("BOGO17"), new NSString("BGH025"))
                                                         );

            WebEngage.SharedInstance().Analytics.TrackEventWithName("Order Placed", orderPlacedAttributes);


            /*
             * Tracking screen
             */
            WebEngage.SharedInstance().Analytics.NavigatingToScreenWithName("Purchase Screen");

            // Screen data
            var screenData = new NSDictionary("productId", "~hs7674",
                                              "price", 1200);

            // Tracking screen with data
            WebEngage.SharedInstance().Analytics.NavigatingToScreenWithName("Purchase Screen", screenData);

            // Updating screen data
            WebEngage.SharedInstance().Analytics.UpdateCurrentScreenData(screenData);
        }
Example #11
0
		// We can send upstream messages back to GCM
		public void SendUpstreamMessage ()
		{            
			var msg = new NSDictionary ();
			msg.SetValueForKey (new NSString ("1234"), new NSString ("userId"));
			msg.SetValueForKey (new NSString ("hello world"), new NSString ("msg"));

			var to = Configuration.GcmSenderId + "@gcm.googleapis.com";

			Log ("Sending Message to: {0}", to);
			Service.SharedInstance.SendMessage (msg, to, (messageId++).ToString ());
		}