
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
react-native-chat-head
Advanced tools
react-native-chat-head
is a React Native library that allows you to create Facebook Messenger-like chat heads for Android applications.
To install the package, use npm or yarn:
npm install react-native-chat-head
# or
yarn add react-native-chat-head
Create android/app/src/main/res/layout/chat_head_layout.xml
with the following content:
<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="65dp"
android:id="@+id/chat_head_root"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<!-- Profile image for the chat head. -->
<ImageView
android:id="@+id/chat_head_profile_iv"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="8dp"
android:src="@mipmap/ic_launcher"
tools:ignore="ContentDescription"
/>
<!-- Close button -->
<ImageView
android:id="@+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="40dp"
android:src="@drawable/ic_close"
tools:ignore="ContentDescription"
/>
<!-- Chat head badge -->
<TextView
android:id="@+id/chat_head_badge"
android:layout_margin="5dp"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_alignParentStart="true"
android:text="1"
/>
</RelativeLayout>
Create android/app/src/main/res/layout/dismiss_icon_layout.xml
with the following content:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
>
<!-- Dismiss icon -->
<ImageView
android:id="@+id/dismiss_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom|center_horizontal"
android:src="@android:drawable/ic_menu_close_clear_cancel"
android:layout_marginBottom="16dp"
/>
</RelativeLayout>
Add an image named ic_close.png
in android/app/src/main/res/drawable-nodpi
.
Import the library and use the provided methods to manage chat heads:
import ChatHead from "react-native-chat-head";
// Check if overlay permission is granted
const hasPermission = await ChatHead.checkOverlayPermission();
// Request overlay permission
await ChatHead.requestPermission();
// Show chat head
ChatHead.showChatHead();
// Hide chat head
ChatHead.hideChatHead();
// Update chat badge count
ChatHead.updateChatBadgeCount(1);
checkOverlayPermission()
: Checks if the overlay permission is granted. Returns a boolean.requestPermission()
: Requests the overlay permission from the user.showChatHead()
: Displays the chat head.hideChatHead()
: Hides the chat head.updateChatBadgeCount(count)
: Updates the badge count on the chat head.We welcome contributions! Please see the contributing guide to learn how to get involved.
This project is licensed under the MIT License. See the LICENSE file for more details.
FAQs
android chat head
The npm package react-native-chat-head receives a total of 12 weekly downloads. As such, react-native-chat-head popularity was classified as not popular.
We found that react-native-chat-head demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.