Java 类com.google.firebase.messaging.FirebaseMessaging 实例源码

项目:CloudFunctionsExample    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.subscribe:
            FirebaseMessaging.getInstance().subscribeToTopic("pushNotifications");
            Toast.makeText(MainActivity.this, "Subscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
            break;
        case R.id.unsubscribe:
            FirebaseMessaging.getInstance().unsubscribeFromTopic("pushNotifications");
            Toast.makeText(MainActivity.this, "Unsubscribed to Topic: Push Notifications", Toast.LENGTH_SHORT).show();
            break;
        case R.id.sign_out_menu:
            AuthUI.getInstance().signOut(this);
            break;

        default:
            return super.onOptionsItemSelected(item);

    }
return true;}
项目:SWGEmuServerStatus    文件:ServerStatusActivity.java   
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_server_status);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.gold));
    setSupportActionBar(toolbar);

    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
        final Intent browserIntent =
                new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.BROWSER_FORUMS_URL));
        startActivity(browserIntent);
        }
    });

    content = (ViewGroup) findViewById(R.id.content);
    sharedPref = getSharedPreferences(
            getString(R.string.preference_file_key), Context.MODE_PRIVATE);
    FirebaseMessaging.getInstance().subscribeToTopic("server-status");
}
项目:1617PROJ1Bloeddonatie-app    文件:SubscribeBloodtypeActivity.java   
private void handlings(String type, View view) {
    if (! bloodType.equals(type)) {
        clearButtons();
        view.setBackgroundColor(getResources().getColor(R.color.button_selected));

        saveInfo(type);
        getInfo();

        unsubscribe();
        FirebaseMessaging.getInstance().subscribeToTopic("blood-" + type);
    } else if(bloodType.equals(type)) {
        clearButtons();
        unsubscribe();
        saveInfo("");
        bloodType = "";
    }
}
项目:CustomAndroidOneSheeld    文件:OneSheeldApplication.java   
@Override
public void onCreate() {
    OneSheeldSdk.init(this);
    context = getApplicationContext();
    setAppPreferences(getSharedPreferences(APP_PREF_NAME, MODE_PRIVATE));
    appFont = Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf");
    parseSocialKeys();
    initTaskerPins();
    isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
    if (isDebuggable() && !FirebaseApp.getApps(this).isEmpty())
        FirebaseMessaging.getInstance().subscribeToTopic("dev");
    OneSheeldSdk.setDebugging(isDebuggable);
    connectionTime = 0;
    AppShields.getInstance().init(getRememberedShields());
    initCrashlyticsAndUncaughtThreadHandler();
    super.onCreate();
}
项目:Tech-Jalsa    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);
    viewPager.setOffscreenPageLimit(ITEM_COUNT);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
                FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
            } else if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) {
                // new push notification is received
            }
        }
    };
}
项目:buddysearch    文件:UsersPresenter.java   
public void signOut() {
    view.showProgress(R.string.signing_out);

    signOutSubscriber = new DefaultSubscriber<String>(view) {
        @Override
        public void onNext(String userId) {
            super.onNext(userId);
            view.hideProgress();
            view.navigateToSplash();
            FirebaseMessaging.getInstance().unsubscribeFromTopic("user_" + userId);
        }

        @Override
        public void onError(Throwable e) {
            super.onError(e);
            view.showMessage(R.string.sign_out_error);
            view.hideProgress();
        }
    };
    authManager.signOut(signOutSubscriber);
}
项目:buddysearch    文件:LoginPresenter.java   
public void signInWithGoogle(GoogleSignInAccount googleSignInAccount) {
    signInSubscriber = new DefaultSubscriber<String>(view) {
        @Override
        public void onNext(String userId) {
            super.onNext(userId);
            view.navigateToUsers();
            view.hideProgress();

            FirebaseMessaging.getInstance().subscribeToTopic("user_" + userId);
        }

        @Override
        public void onError(Throwable e) {
            super.onError(e);
            view.showMessage(R.string.authentication_failed);
            view.hideProgress();
        }
    };
    authManager.signInGoogle(googleSignInAccount, signInSubscriber, createUser);
}
项目:Attendance    文件:EmailPasswordActivity.java   
private void signOut() {
    mAuth.signOut();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString("ustype", "0").apply();
    editor.putString("usadmin", "0").apply();
    editor.putString("usico", "0").apply();
    editor.putString("usosc", "0").apply();
    editor.putString("usatw", "0").apply();
    editor.putString("usuid", "0").apply();
    editor.commit();

    String approvetopic = "approve" + userico;
    String mytopic = "mytopic" + myuserid;

    FirebaseMessaging.getInstance().unsubscribeFromTopic(mytopic);
    FirebaseMessaging.getInstance().unsubscribeFromTopic(approvetopic);


    updateUI(null);
}
项目:BusyBox    文件:MainApp.java   
@Override public void onCreate() {
  super.onCreate();
  MultiDex.install(this);

  // Logging
  if (BuildConfig.DEBUG) {
    Jot.add(new Jot.DebugLogger());
  } else {
    Jot.add(new CrashlyticsLogger());
  }

  // Fabric
  Fabric.with(this, new Crashlytics(), new Answers());
  Analytics.add(AnswersLogger.getInstance());
  // Crashlytics
  Crashlytics.setString("GIT_SHA", BuildConfig.GIT_SHA);
  Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);

  FirebaseMessaging.getInstance().subscribeToTopic("main-" + BuildConfig.FLAVOR);
}
项目:commitstrip-reader    文件:SettingsFragment.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    String keyReceiveNotification = StripSharedPreferencesDataSource.KEY_RECEIVE_NOTIFICATION;

    if (key.compareTo(keyReceiveNotification) == 0) {

        boolean receiveNotification = sharedPreferences.getBoolean(keyReceiveNotification, true);

        FirebaseApp.initializeApp(getActivity().getApplicationContext());

        if (receiveNotification) {
            FirebaseMessaging.getInstance().subscribeToTopic(Configuration.TOPIC_NAME);
        } else {
            FirebaseMessaging.getInstance().unsubscribeFromTopic(Configuration.TOPIC_NAME);
        }
    }
}
项目:commitstrip-reader    文件:IntroActivity.java   
@Override
public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment newFragment) {
    super.onSlideChanged(oldFragment, newFragment);

    currentSlide++;

    if (currentSlide.equals(totalSlides)) {

        if (!getTaskFragment().isJobFinished()) {
            setSwipeLock(true);
            setNextPageSwipeLock(false);
        }

        // Ask Firebase to register the device in the topic. Used for receiving notification.
        FirebaseApp.initializeApp(getApplicationContext());
        FirebaseMessaging.getInstance().subscribeToTopic(Configuration.TOPIC_NAME);
    }
}
项目:IEEE_Malabar    文件:ActivityMain.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_activity_main);

    FirebaseMessaging.getInstance().subscribeToTopic("test");
    FirebaseInstanceId.getInstance().getToken();

    AM = this;
    loadFirebase();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getSupportActionBar().setElevation(0);
    }

    setTitle("All Events");
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    //setRetainInstance(true);
    viewPager.setOffscreenPageLimit(4);
    setAdapterfn();
}
项目:Roach    文件:SettingsActivity.java   
public static void onSettingsChange(SharedPreferences sharedPreferences, Resources resources, String key) {
    switch (key) {
        case NOTIFICATIONS_NEWS:
            unsubscribeFromAllNews(resources);
            String news = sharedPreferences.getString(NOTIFICATIONS_NEWS, "none");

            if (news.equals("none")) {
                break;
            }

            String topic = "news-" + news;
            FirebaseMessaging.getInstance().subscribeToTopic(topic);
            if (BuildConfig.DEBUG) {
                FirebaseMessaging.getInstance().subscribeToTopic(topic + "-debug");
            }
            break;
        case NOTIFICATIONS_PATCH:
            checkAndUpdatePatchTopic(sharedPreferences, resources);
            break;
    }
}
项目:Roach    文件:SettingsActivity.java   
public static void checkAndUpdatePatchTopic(SharedPreferences sharedPreferences, Resources resources) {
    boolean subscribed = sharedPreferences.getBoolean(NOTIFICATIONS_PATCH, true);
    String intendedTopic = "patch-" + BuildConfig.CARD_DATA_VERSION;
    String key = resources.getString(R.string.pref_patch_notifications_topic_key);
    String topic = sharedPreferences.getString(key, null);
    if (subscribed) {
        if (!intendedTopic.equals(topic)) {
            if (topic != null) {
                FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
            }
            FirebaseMessaging.getInstance().subscribeToTopic(intendedTopic);
            sharedPreferences.edit().putString(key, intendedTopic).apply();
        }
    } else {
        if (topic != null) {
            FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
            sharedPreferences.edit().remove(key).apply();
        }
    }
}
项目:1Sheeld-Android-App    文件:OneSheeldApplication.java   
@Override
public void onCreate() {
    OneSheeldSdk.init(this);
    context = getApplicationContext();
    setAppPreferences(getSharedPreferences(APP_PREF_NAME, MODE_PRIVATE));
    appFont = Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf");
    parseSocialKeys();
    initTaskerPins();
    isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
    if (isDebuggable() && !FirebaseApp.getApps(this).isEmpty())
        FirebaseMessaging.getInstance().subscribeToTopic("dev");
    OneSheeldSdk.setDebugging(isDebuggable);
    connectionTime = 0;
    AppShields.getInstance().init(getRememberedShields());
    initCrashlyticsAndUncaughtThreadHandler();
    detectIfLocatedInTheUs();
    super.onCreate();
}
项目:the-ssn-app    文件:DepartmentAlertsFragment.java   
private void switchTopicSubscription(String topic) {
    FirebaseMessaging.getInstance().subscribeToTopic(topic);
    LogHelper.d(TAG, "Subscribed to " + topic);

    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean("notifications_department_" + topic, true);

    for (String departmentKey : departmentKeys) {
        if (departmentKey.equals(topic)) {
            continue;
        }

        FirebaseMessaging.getInstance().unsubscribeFromTopic(departmentKey);
        LogHelper.d(TAG, "Unsubscribed from " + departmentKey);
        editor.putBoolean("notifications_department_" + departmentKey, false);
    }

    editor.apply();
}
项目:the-ssn-app    文件:SettingsActivity.java   
private void switchTopicSubscription(String topic) {
    String key = "notifications_" + topic;

    SharedPreferences.Editor editor;
    if (sharedPreferences.getBoolean(key, false)) {
        FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
        LogHelper.d(TAG, "Unsubscribed from " + topic);
        editor = sharedPreferences.edit();
        editor.putBoolean(key, false);
    } else {
        FirebaseMessaging.getInstance().subscribeToTopic(topic);
        LogHelper.d(TAG, "Subscribed to " + topic);
        editor = sharedPreferences.edit();
        editor.putBoolean(key, true);
    }
    editor.apply();
}
项目:iosched    文件:FcmUtilities.java   
public static void subscribeTopics(boolean isConfMessageCardsEnabled, boolean isRegisteredAttendee) {
    try {
        FirebaseMessaging pubSub = FirebaseMessaging.getInstance();
        if (isConfMessageCardsEnabled) {
            if (isRegisteredAttendee) {
                pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
                pubSub.subscribeToTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
            } else {
                pubSub.subscribeToTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
                pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
            }
        } else {
            pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_ONSITE);
            pubSub.unsubscribeFromTopic(CONFERENCE_MESSAGES_TOPIC_OFFSITE);
        }
    } catch (Throwable throwable) {
        // Just in case.
        LOGE(TAG, "Exception updating conference message cards subscription.", throwable);
    }
}
项目:friendlychat-android    文件:MyFirebaseInstanceIdService.java   
/**
 * The Application's current Instance ID token is no longer valid and thus a new one must be requested.
 */
@Override
public void onTokenRefresh() {
    // If you need to handle the generation of a token, initially or after a refresh this is
    // where you should do that.
    String token = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "FCM Token: " + token);

    // Once a token is generated, we subscribe to topic.
    FirebaseMessaging.getInstance().subscribeToTopic(FRIENDLY_ENGAGE_TOPIC);
}
项目:GodotFireBase    文件:Notification.java   
public void sendMessage (final String data) {
    FirebaseMessaging fm = FirebaseMessaging.getInstance();

    String token = FirebaseInstanceId.getInstance().getToken();
    String msgID = DigestUtils.sha1Hex(token + System.currentTimeMillis());
    String SENDER_ID = "someID";

    RemoteMessage.Builder RMBuilder =
    new RemoteMessage.Builder(SENDER_ID + "@gcm.googleapis.com");
    RMBuilder.setMessageId(msgID);

    Map<String, Object> mapData = Utils.jsonToMap(data);

    for (Map.Entry<String, Object> entry : mapData.entrySet()) {
        RMBuilder.addData(entry.getKey(), entry.getValue().toString());
    }

    fm.send(RMBuilder.build());
}
项目:CloudFunctionsExample    文件:MyFirebaseInstanceIdService.java   
@Override
public void onTokenRefresh() {
    // If you need to handle the generation of a token, initially or
    // after a refresh this is where you should do that.
    String token = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "FCM Token: " + token);

    // Once a token is generated, we subscribe to topic.
    FirebaseMessaging.getInstance()
            .subscribeToTopic(FRIENDLY_ENGAGE_TOPIC);
}
项目:kolibri-android    文件:KolibriPrototypeApp.java   
@Override
public void onCreate() {
  super.onCreate();
  Fabric.with(this, new Crashlytics());
  setFirebaseEnabled(false);

  FirebaseMessaging.getInstance().subscribeToTopic("main");
}
项目:cordova-plugin-firebase-sdk    文件:MessagingComponent.java   
public void subscribe(final CallbackContext callbackContext, final String topic) {
    mFirebase.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            try {
                Log.i(TAG, "Subscribing to topic " + topic);
                FirebaseMessaging.getInstance().subscribeToTopic(topic);
                callbackContext.success();
            } catch (Exception e) {
                Log.e(TAG, "Error subscribing to topic " + topic);
                callbackContext.error(e.getMessage());
            }
        }
    });
}
项目:cordova-plugin-firebase-sdk    文件:MessagingComponent.java   
public void unsubscribe(final CallbackContext callbackContext, final String topic) {
    mFirebase.cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            try {
                Log.i(TAG, "Unsubscribing from topic " + topic);
                FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
                callbackContext.success();
            } catch (Exception e) {
                Log.e(TAG, "Error unsubscribing from topic " + topic);
                callbackContext.error(e.getMessage());
            }
        }
    });
}
项目:Android-2017    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_layout);

    // suscirpcion a los temas de mensajeria. para una aplicación concreta solo recibiremos notificaciones
    // de los temas a los que estemos suscritos.
    FirebaseMessaging.getInstance().subscribeToTopic("test_mensajeria");


}
项目:1617PROJ1Bloeddonatie-app    文件:SubscribeBloodtypeActivity.java   
private void unsubscribe() {
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-Ap");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-Bp");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-ABp");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-Op");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-An");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-Bn");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-ABn");
    FirebaseMessaging.getInstance().unsubscribeFromTopic("blood-On");
}
项目:firebase-chat-android-architecture-components    文件:MyFirebaseInstanceIdService.java   
/**
 * The Application's current Instance ID token is no longer valid and thus a new one must be requested.
 */
@Override
public void onTokenRefresh() {
    // If you need to handle the generation of a token, initially or after a refresh this is
    // where you should do that.
    String token = FirebaseInstanceId.getInstance().getToken();

    // Once a token is generated, we subscribe to topic.
    FirebaseMessaging.getInstance().subscribeToTopic(FRIENDLY_ENGAGE_TOPIC);
}
项目:Trinity-App    文件:MainActivity.java   
private void subscribeToPushService() {
    FirebaseMessaging.getInstance().subscribeToTopic("news");

    Log.d("AndroidBash", "Subscribed");
    //Toast.makeText(MainActivity.this, "Subscribed", Toast.LENGTH_SHORT).show();

    String token = FirebaseInstanceId.getInstance().getToken();

    // Log and toast
    Log.d("AndroidBash", token);
    //Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
}
项目:LNMOnlineAndroidSample    文件:NotificationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notification);

    txtRegId = (EditText) findViewById(R.id.txt_reg_id);
    txtMessage = (TextView) findViewById(R.id.txt_push_message);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            // checking for type intent filter
            if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
                // gcm successfully registered
                // now subscribe to `global` topic to receive app wide notifications
                FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);

                displayFirebaseRegId();

            } else if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) {
                // new push notification is received

                String message = intent.getStringExtra("message");

                Toast.makeText(getApplicationContext(), "Push notification: " + message, Toast.LENGTH_LONG).show();

                txtMessage.setText(message);
            }
        }
    };

    displayFirebaseRegId();
}
项目:underlx    文件:MainService.java   
public void reloadFCMsubscriptions() {
    FirebaseMessaging fcm = FirebaseMessaging.getInstance();
    SharedPreferences sharedPref = getSharedPreferences("notifsettings", MODE_PRIVATE);
    Set<String> linePref = sharedPref.getStringSet("pref_notifs_lines", null);
    if (linePref != null && linePref.size() != 0) {
        fcm.subscribeToTopic("disturbances");
        if (BuildConfig.DEBUG) {
            fcm.subscribeToTopic("disturbances-debug");
        }
    } else {
        fcm.unsubscribeFromTopic("disturbances");
        fcm.unsubscribeFromTopic("disturbances-debug");
    }

    Set<String> sourcePref = sharedPref.getStringSet("pref_notifs_announcement_sources", null);

    for (Announcement.Source possibleSource : Announcement.getSources()) {
        if (sourcePref != null && sourcePref.contains(possibleSource.id)) {
            fcm.subscribeToTopic("announcements-" + possibleSource.id);
            if (BuildConfig.DEBUG) {
                fcm.subscribeToTopic("announcements-debug-" + possibleSource.id);
            }
        } else {
            fcm.unsubscribeFromTopic("announcements-" + possibleSource.id);
            fcm.unsubscribeFromTopic("announcements-debug-" + possibleSource.id);
        }
    }
}
项目:FCM-toolbox    文件:TokenFetcher.java   
@Override
protected String doInBackground(Void... params) {
    try {
        return FirebaseInstanceId.getInstance().getToken(context.getString(R.string.gcm_defaultSenderId), FirebaseMessaging.INSTANCE_ID_SCOPE);
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
项目:blockvote    文件:BlockvoteProviderService.java   
@Override
public void onComplicationActivated(int complicationId, int type, ComplicationManager manager) {
    // register FCM topic
    FirebaseMessaging.getInstance().subscribeToTopic("v1");
    if (BuildConfig.DEBUG) {
        FirebaseMessaging.getInstance().subscribeToTopic("debug");
    }
}
项目:blockvote    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // init google services
    GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this);
    FirebaseMessaging.getInstance().subscribeToTopic("v1");
    if (BuildConfig.DEBUG) {
        FirebaseMessaging.getInstance().subscribeToTopic("debug");
    }

    // bind views
    statsView = findViewById(R.id.stats);
    historyView = findViewById(R.id.card_history);
    historyView.setOnRetryListener(this::onRetryHistory);

    // get viewmodel
    viewModel = ViewModelProviders.of(this).get(MainViewModel.class);
    // TODO get rid of this line?
    viewModel.init(this);
    viewModel.observeData(this, this::onHistoryUpdated);
    viewModel.loadHistory();

    // bind ticker
    Ticker.with(this).bind(this::onTick);

    // load stats
    getSupportLoaderManager().initLoader(0, null, this);
}
项目:FcmNotificationHandler    文件:MainActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        intentDetails = (TextView) findViewById(R.id.intentDetails);

//        String token = FirebaseInstanceId.getInstance().getToken();
        FirebaseMessaging.getInstance().subscribeToTopic("fcm_testing");

        showIntentDetails();
    }
项目:OSTMiniProject    文件:LoginActivity.java   
void goToActivity(String userType) {
    if (userType.equals("1")) {
        startActivity(new Intent(LoginActivity.this, MainNavigation.class));
        Config.TOPIC_GLOBAL = "student";
        FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
    } else if (userType.equals("0")) {
        startActivity(new Intent(LoginActivity.this, TeacherNavigation.class));
        Config.TOPIC_GLOBAL = "teacher";
        FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
    }
}
项目:android-things-electricity-monitor    文件:ElectricityApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    CalligraphyConfig.initDefault(
            new CalligraphyConfig.Builder().setDefaultFontPath("minyna.ttf").setFontAttrId(R.attr.fontPath)
                    .build());
    AndroidThreeTen.init(this);
    FirebaseApp.initializeApp(this);
    FirebaseMessaging.getInstance().subscribeToTopic("Power_Notifications");
}
项目:Bee-Analyzer    文件:StartingActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_starting);
    //Push Notification Common Subscription Topic
    FirebaseMessaging.getInstance().subscribeToTopic("news");
}
项目:react-native-fcm    文件:FIRMessagingModule.java   
@ReactMethod
public void send(String senderId, ReadableMap payload) throws Exception {
    FirebaseMessaging fm = FirebaseMessaging.getInstance();
    RemoteMessage.Builder message = new RemoteMessage.Builder(senderId + "@gcm.googleapis.com")
    .setMessageId(UUID.randomUUID().toString());

    ReadableMapKeySetIterator iterator = payload.keySetIterator();
    while (iterator.hasNextKey()) {
        String key = iterator.nextKey();
        String value = getStringFromReadableMap(payload, key);
        message.addData(key, value);
    }
    fm.send(message.build());
}
项目:buddysearch    文件:App.java   
@Override
public void onCreate() {
    super.onCreate();
    initRealm();
    initializeInjector();
    initializeLeakDetection();
    networkManager.start();

    if (authManager.isSignedIn()) {
        FirebaseMessaging.getInstance().subscribeToTopic("user_" + authManager.getCurrentUserId());
    }
}
项目:buddysearch    文件:App.java   
@Override
public void onTerminate() {
    super.onTerminate();
    networkManager.stop();
    if (authManager.isSignedIn()) {
        FirebaseMessaging.getInstance().unsubscribeFromTopic("user_" + authManager.getCurrentUserId());
    }
}