示例#1
0
        void ProcessReferralIntent(Intent intent)
        {
            if (!AppInviteReferral.HasReferral(intent))
            {
                Log.Error(Tag, "Error: DeepLinkActivity Intent does not contain App Invite");
                return;
            }

            var invitationId = AppInviteReferral.GetInvitationId(intent);
            var deepLink     = AppInviteReferral.GetDeepLink(intent);

            Log.Debug(Tag, "Found Referral: " + invitationId + ":" + deepLink);
            (FindViewById <TextView> (Resource.Id.deep_link_text)).Text     = string.Format(deepLink, GetString(Resource.String.deep_link_fmt));
            (FindViewById <TextView> (Resource.Id.invitation_id_text)).Text = string.Format(invitationId, GetString(Resource.String.invitation_id_fmt));

            if (googleApiClient.IsConnected)
            {
                UpdateInvitationStatus(intent);
            }
            else
            {
                Log.Warn(Tag, "Warning: GoogleAPIClient not connected, can't update invitation.");
                cachedInvitationIntent = intent;
            }
        }
示例#2
0
        void ProcessReferralIntent(Intent intent)
        {
            if (!AppInviteReferral.HasReferral(intent))
            {
                if (needsRefresh)
                {
                    RefreshData();
                }
                return;
            }

            Xamarin.Insights.Track("AppInvite-Accepted");

            var invitationId = AppInviteReferral.GetInvitationId(intent);
            var deepLink     = AppInviteReferral.GetDeepLink(intent);

            Console.WriteLine("Referral found: invitationId: " + invitationId + " deepLink: " + deepLink);

            var info = deepLink.Replace("http://motzcod.es/coffee/", string.Empty);

            viewModel.Place.PlaceId = info;
            RefreshData();


            if (client.IsConnected)
            {
                UpdateInvitationStatus(intent);
            }
            else
            {
                Console.WriteLine("Warning: GoogleAPIClient not connect, can't update invitation just yet.");
                cachedInvitationIntent = intent;
            }
        }
示例#3
0
        // [END deep_link_on_start]

        // [START process_referral_intent]
        private void ProcessReferralIntent(Intent intent)
        {
            // Extract referral information from the intent
            string invitationId = AppInviteReferral.GetInvitationId(intent);
            string deepLink     = AppInviteReferral.GetDeepLink(intent);

            // Display referral information
            // [START_EXCLUDE]
            Console.WriteLine(TAG, "Found Referral: " + invitationId + ":" + deepLink);
            ((TextView)FindViewById(Resource.Id.deep_link_text))
            .SetText(Resource.String.deep_link_fmt);
            ((TextView)FindViewById(Resource.Id.invitation_id_text))
            .SetText(Resource.String.invitation_id_fmt);
            // [END_EXCLUDE]
        }
示例#4
0
        // [END define_variables]

        // [START on_create]
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // [START_EXCLUDE]
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.main_activity);

            // Invite button click listener
            FindViewById(Resource.Id.invite_button).SetOnClickListener(this);
            // [END_EXCLUDE]

            // Create an auto-managed GoogleApiClient with access to App Invites.
            mGoogleApiClient = new GoogleApiClient.Builder(this)
                               .AddApi(AppInviteClass.API)
                               .EnableAutoManage(this, this)
                               .Build();

            // Check for App Invite invitations and launch deep-link activity if possible.
            // Requires that an Activity is registered in AndroidManifest.xml to handle
            // deep-link URLs.
            bool autoLaunchDeepLink = true;

            AppInviteClass.AppInviteApi.GetInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
            .SetResultCallback(
                new ResultCallback <IAppInviteInvitationResult>((IAppInviteInvitationResult result) =>
            {
                Console.WriteLine(TAG, string.Format("getInvitation:onResult:{0}", result.Status));
                if (result.Status.IsSuccess)
                {
                    // Extract information from the intent
                    Intent intent       = result.InvitationIntent;
                    String deepLink     = AppInviteReferral.GetDeepLink(intent);
                    String invitationId = AppInviteReferral.GetInvitationId(intent);

                    // Because autoLaunchDeepLink = true we don't have to do anything
                    // here, but we could set that to false and manually choose
                    // an Activity to launch to handle the deep link here.
                    // ...
                }
            }));
        }