Esempio n. 1
0
        public void CheckLocationStatus()
        {
            MarketingCloudSdk.RequestSdk(new SdkReady {
                OnReady = sdk => {
                    var status       = sdk.InitializationStatus;
                    var availability = GoogleApiAvailability.Instance;

                    if (status.LocationsError())
                    {
                        Log.Error(TAG, string.Format("MarketingCloudSdk Locations error: {0}", status.PlayServicesStatus()));
                        Log.Info(TAG, string.Format("Google Play Services Availability: {0}", availability.GetErrorString(status.PlayServicesStatus())));

                        if (availability.IsUserResolvableError(status.PlayServicesStatus()))
                        {
                            Log.Error(TAG, "User resolvable error");
                            availability.ShowErrorNotification(this, status.PlayServicesStatus());
                        }
                        else
                        {
                            Log.Error(TAG, "Unresolvable error ");
                            Log.Error(TAG, "Play Service status: " + status.PlayServicesStatus());
                            Log.Error(TAG, "Play Service message: " + status.PlayServicesMessage());
                        }
                    }
                    else
                    {
                        Log.Debug(TAG, "MarketingCloudSdk Geofencing Success");
                    }
                }
            });
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            txtTest = FindViewById <TextView>(Resource.Id.txtTest);

            UpdateSubscriberKey();

            ArePlayServicesAvailable();
            RequestLocationPermission();

            txtTest.Text += "\nFirebase Token: " + FirebaseInstanceId.Instance.Token + "\n";
            Log.Info(TAG, "Firebase Token: " + FirebaseInstanceId.Instance.Token + "\n");

            CheckLocationStatus();

            MarketingCloudSdk.RequestSdk(new SdkReady {
                OnReady = sdk => {
                    txtTest.Text += "\nSDK State:\n" + sdk.SdkState.ToString(2) + "\n";
                }
            });
        }
Esempio n. 3
0
        private void InitMarketingCloud()
        {
            MarketingCloudSdk.LogLevel = BuildConfig.Debug ? MCLogListener.Debug : MCLogListener.Error;
            MarketingCloudSdk.SetLogListener(new MCLogListenerAndroidLogListener());

            MarketingCloudConfig.Builder builder = MarketingCloudConfig.InvokeBuilder()
                                                   // Set Salesforce Marketing Cloud instance details
                                                   .SetApplicationId(APPLICATION_ID)
                                                   .SetAccessToken(ACCESS_TOKEN)
                                                   .SetMarketingCloudServerUrl(SERVER_URL)
                                                   .SetMid(MID)

                                                   // Set the Firebase service key
                                                   .SetSenderId(FIREBASE_SERVER_KEY)

                                                   // Enable SDK Features
                                                   .SetAnalyticsEnabled(true)
                                                   .SetPiAnalyticsEnabled(true)
                                                   .SetInboxEnabled(true)
                                                   .SetGeofencingEnabled(true)

                                                   // Disable beacon messaging for now
                                                   .SetProximityEnabled(false)
                                                   .SetNotificationCustomizationOptions(
                NotificationCustomizationOptions.Create(
                    Resource.Drawable.abc_ic_ab_back_material,
                    new LaunchIntentProvider(),
                    new ChannelProvider()
                    )
                );

            MarketingCloudSdk.Init(this, builder.Build(this), this);
        }
Esempio n. 4
0
 public void UpdateSubscriberKey()
 {
     MarketingCloudSdk.RequestSdk(new SdkReady {
         OnReady = sdk => sdk.RegistrationManager
                   .Edit()
                   .SetContactKey("1002")
                   .SetAttribute("FirstName", "Hello")
                   .SetAttribute("LastName", "World")
                   .Commit()
     });
 }
        public override void OnMessageReceived(RemoteMessage message)
        {
            var notification = message.GetNotification();

            Log.Debug(TAG, $"From: {message.From}");
            Log.Debug(TAG, $"Data: {message.Data.ToString()}");
            Log.Debug(TAG, $"{ message.ToString() }");

            if (PushMessageManager.IsMarketingCloudPush(message.Data))
            {
                Log.Debug(TAG, "Marketing Cloud Message");
                MarketingCloudSdk.RequestSdk(new SdkReady {
                    OnReady = sdk => sdk.PushMessageManager.HandleMessage(message.Data)
                });
            }
            else
            {
                Log.Debug(TAG, "Normal Message");
                SendNotification(notification, message.Data);
            }
        }
Esempio n. 6
0
 public void EnableGeofencing()
 {
     MarketingCloudSdk.RequestSdk(new SdkReady {
         OnReady = sdk => sdk.RegionMessageManager.EnableGeofenceMessaging()
     });
 }
Esempio n. 7
0
 public void Ready(MarketingCloudSdk sdk) => OnReady?.Invoke(sdk);