Java Code Examples for com.facebook.react.bridge.Arguments#toBundle()

The following examples show how to use com.facebook.react.bridge.Arguments#toBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNPushNotification.java    From react-native-push-notification-CE with MIT License 5 votes vote down vote up
@ReactMethod
public void presentLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    // If notification ID is not provided by the user, generate one at random
    if (bundle.getString("id") == null) {
        bundle.putString("id", String.valueOf(mRandomNumberGenerator.nextInt()));
    }
    mRNPushNotificationHelper.sendToNotificationCentre(bundle);
}
 
Example 2
Source File: RNPushNotification.java    From react-native-push-notification-CE with MIT License 5 votes vote down vote up
@ReactMethod
public void scheduleLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    // If notification ID is not provided by the user, generate one at random
    if (bundle.getString("id") == null) {
        bundle.putString("id", String.valueOf(mRandomNumberGenerator.nextInt()));
    }
    mRNPushNotificationHelper.sendNotificationScheduled(bundle);
}
 
Example 3
Source File: RNInvokeApp.java    From react-native-invoke-app with MIT License 5 votes vote down vote up
@ReactMethod
public void invokeApp(ReadableMap params) {
    ReadableMap data = params.hasKey("data") ? params.getMap("data") : null;

    if (data != null) {
        bundle = Arguments.toBundle(data);
    }

    String packageName = reactContext.getPackageName();
    Intent launchIntent = reactContext.getPackageManager().getLaunchIntentForPackage(packageName);
    String className = launchIntent.getComponent().getClassName();

    try {
        Class<?> activityClass = Class.forName(className);
        Intent activityIntent = new Intent(reactContext, activityClass);

        activityIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        reactContext.startActivity(activityIntent);
    } catch(Exception e) {
        Log.e(LOG_TAG, "Class not found", e);
        return;
    }

    if (isAppOnForeground(reactContext)) {
        sendEvent();
    }
}
 
Example 4
Source File: NavBarStyle.java    From react-native-turbolinks with MIT License 5 votes vote down vote up
private NavBarStyle(ReadableMap rp) {
    ReadableMap menuIcon = rp.hasKey(MENU_ICON) ? rp.getMap(MENU_ICON) : null;
    this.titleTextColor = rp.hasKey(TITLE_TEXT_COLOR) && !rp.isNull(TITLE_TEXT_COLOR) ? rp.getInt(TITLE_TEXT_COLOR) : null;
    this.subtitleTextColor = rp.hasKey(SUBTITLE_TEXT_COLOR) && !rp.isNull(SUBTITLE_TEXT_COLOR) ? rp.getInt(SUBTITLE_TEXT_COLOR) : null;
    this.barTintColor = rp.hasKey(BAR_TINT_COLOR) && !rp.isNull(BAR_TINT_COLOR) ? rp.getInt(BAR_TINT_COLOR) : null;
    this.menuIcon = menuIcon != null ? Arguments.toBundle(menuIcon) : null;
}
 
Example 5
Source File: TurbolinksRoute.java    From react-native-turbolinks with MIT License 5 votes vote down vote up
public TurbolinksRoute(ReadableMap rp) {
    ReadableMap props = rp.hasKey("passProps") ? rp.getMap("passProps") : null;
    ReadableArray actions = rp.hasKey("actions") ? rp.getArray("actions") : null;
    this.url = rp.hasKey("url") ? rp.getString("url") : null;
    this.component = rp.hasKey("component") ? rp.getString("component") : null;
    this.action = rp.hasKey("action") ? rp.getString("action") : ACTION_ADVANCE;
    this.modal = rp.hasKey("modal") && rp.getBoolean("modal");
    this.dismissable = rp.hasKey("dismissable") && rp.getBoolean("dismissable");
    this.passProps = props != null ? Arguments.toBundle(props) : null;
    this.title = rp.hasKey("title") ? rp.getString("title") : null;
    this.subtitle = rp.hasKey("subtitle") ? rp.getString("subtitle") : null;
    this.visibleDropDown = rp.hasKey("visibleDropDown") && rp.getBoolean("visibleDropDown");
    this.hidesNavBar = rp.hasKey("hidesNavBar") && rp.getBoolean("hidesNavBar");
    this.actions = rp.hasKey("actions") ? Arguments.toList(actions) : null;
}
 
Example 6
Source File: RNPushNotification.java    From react-native-push-notification with MIT License 5 votes vote down vote up
@ReactMethod
public void presentLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    // If notification ID is not provided by the user, generate one at random
    if (bundle.getString("id") == null) {
        bundle.putString("id", String.valueOf(mRandomNumberGenerator.nextInt()));
    }
    mRNPushNotificationHelper.sendToNotificationCentre(bundle);
}
 
Example 7
Source File: RNPushNotification.java    From react-native-push-notification with MIT License 5 votes vote down vote up
@ReactMethod
public void scheduleLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    // If notification ID is not provided by the user, generate one at random
    if (bundle.getString("id") == null) {
        bundle.putString("id", String.valueOf(mRandomNumberGenerator.nextInt()));
    }
    mRNPushNotificationHelper.sendNotificationScheduled(bundle);
}
 
Example 8
Source File: FIRMessagingModule.java    From react-native-fcm with MIT License 4 votes vote down vote up
@ReactMethod
public void presentLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    mFIRLocalMessagingHelper.sendNotification(bundle);
}
 
Example 9
Source File: FIRMessagingModule.java    From react-native-fcm with MIT License 4 votes vote down vote up
@ReactMethod
public void scheduleLocalNotification(ReadableMap details) {
    Bundle bundle = Arguments.toBundle(details);
    mFIRLocalMessagingHelper.sendNotificationScheduled(bundle);
}