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; } }
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; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); #if DEBUG Xamarin.Insights.Initialize("ef02f98fd6fb47ce8624862ab7625b933b6fb21d", this); #else Xamarin.Insights.Initialize("8da86f8b3300aa58f3dc9bbef455d0427bb29086", this); #endif mapView = FindViewById <MapView> (Resource.Id.map); mapView.OnCreate(bundle); mapView.Visibility = ViewStates.Invisible; viewModel = new CoffeeFilterViewModel(); ServiceContainer.Register <CoffeeFilterViewModel> (viewModel); adapter = new PlacesPagerAdapter(SupportFragmentManager, viewModel); pager = FindViewById <ViewPager> (Resource.Id.pager); pager.Adapter = adapter; progressBar = FindViewById <ImageView> (Resource.Id.progressBar); errorImage = FindViewById <ImageView> (Resource.Id.error); coffeeProgress = (AnimationDrawable)progressBar.Background; progressBar.Visibility = ViewStates.Gone; pager.PageSelected += (sender, e) => UpdateMap(e.Position); pager.PageScrollStateChanged += (sender, e) => { if (e.State == (int)ScrollState.TouchScroll) { refresher.Enabled = false; } else { refresher.Enabled = true; } }; refresher = FindViewById <SwipeRefreshLayout> (Resource.Id.refresher); refresher.SetColorSchemeColors(Resource.Color.accent); refresher.Refresh += (sender, args) => { RefreshData(true); refresher.PostDelayed(() => { refresher.Refreshing = false; }, 250); }; SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); mapView.GetMapAsync(this); CheckGooglePlayServices(); // No savedInstanceState, so it is the first launch of this activity if (bundle == null && AppInviteReferral.HasReferral(Intent)) { // In this case the referral data is in the intent launching the MainActivity, // which means this user already had the app installed. We do not have to // register the Broadcast Receiver to listen for Play Store Install information LaunchDeepLinkActivity(Intent); } }
public override void OnReceive(Context context, Intent intent) { if (!AppInviteReferral.HasReferral(intent)) { return; } activity.LaunchDeepLinkActivity(intent); }
// [START deep_link_on_start] protected override void OnStart() { base.OnStart(); // Check if the intent contains an AppInvite and then process the referral information. Intent intent = Intent; if (AppInviteReferral.HasReferral(intent)) { ProcessReferralIntent(intent); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var button = FindViewById <Button> (Resource.Id.buttonInvite); button.Click += delegate { SendAppInvite(); }; googleApiClient = new GoogleApiClient.Builder(this) .AddApi(AppInviteClass.API) .AddConnectionCallbacks(async info => { if (AppInviteReferral.HasReferral(Intent)) { await UpdateInvitationStatus(Intent); } }, cause => Console.WriteLine("Connection Suspended: {0}", cause)) .AddOnConnectionFailedListener(result => { if (!result.IsSuccess) { if (result.HasResolution) { result.StartResolutionForResult(this, RESOLUTION_CODE); } else { Toast.MakeText(this, "Failed to Connect: " + result.ErrorCode, ToastLength.Long).Show(); } } }) .Build(); // If the app was already installed and the appinvite was opened // we may have information passed in about it here if (bundle == null) { // No savedInstanceState, so it is the first launch of this activity if (AppInviteReferral.HasReferral(Intent)) { // In this case the referral data is in the intent launching the MainActivity, // which means this user already had the app installed. We do not have to // register the Broadcast Receiver to listen for Play Store Install information LaunchDeepLinkActivity(Intent); } } }
void RegisterDeepLinkReceiver() { deepLinkReceiver = new BroadcastReceiver(); deepLinkReceiver.OnReceiveImpl = (context, intent) => { if (AppInviteReferral.HasReferral(intent)) { LaunchDeepLinkActivity(intent); } }; var intentFilter = new IntentFilter(GetString(Resource.String.action_deep_link)); LocalBroadcastManager.GetInstance(this).RegisterReceiver( deepLinkReceiver, intentFilter); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.main_activity); FindViewById(Resource.Id.invite_button).SetOnClickListener(this); if (savedInstanceState == null) { var intent = Intent; if (AppInviteReferral.HasReferral(intent)) { LaunchDeepLinkActivity(intent); } } }
void RegisterDeepLinkReceiver() { // Create local Broadcast receiver that starts DeepLinkActivity when a deep link // is found deepLinkReceiver = new LocalBroadcastReceiver { OnReceiveHandler = (context, intent) => { if (AppInviteReferral.HasReferral(intent)) { LaunchDeepLinkActivity(intent); } } }; var intentFilter = new IntentFilter(GetString(Resource.String.action_deep_link)); LocalBroadcastManager.GetInstance(this).RegisterReceiver(deepLinkReceiver, intentFilter); }