๐ŸŽฏ firebase_fcm_token

pub package License: MIT

A lightweight Flutter package for app status control with server integration and admin panel. Control your app remotely, crash the app when disabled by server, and manage everything through admin panel.

๐Ÿšจ Critical Feature: App Crash on Disable

When your app is disabled by the server, the application will immediately crash with an Exception instead of showing a white screen. This ensures complete app control and prevents unauthorized usage.

โญ Features

  • ๐Ÿšซ App Crash Control - Crashes app immediately when disabled by server
  • ๐Ÿ”ฅ Exception Throwing - Throws clear exception: "UYGULAMA Yร–NETฤฐCฤฐ TARAFINDAN KAPATILMIลžTIR!"
  • ๐Ÿ›‘ Mandatory Stop - No bypass possible, app terminates completely
  • ๐ŸŒ Server Integration - Connect to your PHP server or custom backend
  • ๐Ÿ‘จโ€๐Ÿ’ผ Admin Panel - Web-based control panel for managing apps
  • ๐Ÿ“ฑ Lightweight - No Firebase dependencies, HTTP-only communication
  • โšก Fast Setup - Easy integration in 5 minutes

๐Ÿš€ Quick Start

1. Add to pubspec.yaml

dependencies:
  firebase_fcm_token: ^1.1.3

2. Initialize in main.dart

import 'package:flutter/material.dart';
import 'package:firebase_fcm_token/firebase_fcm_token.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Initialize app control
  await FirebaseFcmToken().initialize(
    appName: 'my_awesome_app',
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return FirebaseFcmToken().buildAppStatusWidget(
      child: MaterialApp(
        title: 'My App',
        home: const HomePage(),
      ),
    );
  }
}

โš ๏ธ Behavior When App Disabled

When the server disables your app:

  1. Immediate Exception: App throws Exception('UYGULAMA Yร–NETฤฐCฤฐ TARAFINDAN KAPATILMIลžTIR! Program sonlandฤฑrฤฑlฤฑyor...')
  2. App Crash: Application terminates immediately
  3. No Bypass: Users cannot continue using the app
  4. Clear Message: Error message explains why app crashed

๐Ÿ”ง API Reference

FirebaseFcmToken Class

initialize()

await FirebaseFcmToken().initialize(
  appName: 'your_app_name',    // Required: Your app identifier
  serverUrl: 'https://...',    // Optional: Custom server URL
);

buildAppStatusWidget()

Widget buildAppStatusWidget({required Widget child})

Returns a widget that crashes the app if disabled by server.

refreshAppStatus()

await FirebaseFcmToken().refreshAppStatus();

Manually refresh app status from server. Will crash app if disabled.

isAppEnabled

bool isEnabled = FirebaseFcmToken().isAppEnabled;

Check if app is currently enabled (before crash).

๐ŸŒ Server Setup

Upload the included PHP files to your server:

your-domain.com/
โ”œโ”€โ”€ server/
โ”‚   โ”œโ”€โ”€ index.php          # API endpoint
โ”‚   โ”œโ”€โ”€ admin/
โ”‚   โ”‚   โ”œโ”€โ”€ index.php      # Admin panel
โ”‚   โ”‚   โ””โ”€โ”€ style.css      # Admin styles
โ”‚   โ””โ”€โ”€ config.php         # Database config

Database Structure

CREATE TABLE apps (
    id INT AUTO_INCREMENT PRIMARY KEY,
    app_name VARCHAR(100) UNIQUE NOT NULL,
    is_enabled BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

Admin Panel Access

  • URL: https://yourdomain.com/server/admin/
  • Password: admin123 (change in config.php)

๐Ÿ›ก๏ธ Security Features

  • Forced Crash: No way to bypass disabled state
  • Exception Handling: Clear error messages
  • Server Validation: Regular status checks
  • Admin Control: Secure web panel access

๐Ÿ“ Example Usage

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final FirebaseFcmToken _controller = FirebaseFcmToken();

  Future<void> _checkStatus() async {
    try {
      // This will crash the app if disabled by server
      await _controller.refreshAppStatus();
      
      // This code only runs if app is enabled
      print('App is enabled: ${_controller.isAppEnabled}');
    } catch (e) {
      // App crashed due to being disabled
      print('App disabled and crashed: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('My App')),
      body: Center(
        child: ElevatedButton(
          onPressed: _checkStatus,
          child: Text('Check Status'),
        ),
      ),
    );
  }
}

๐Ÿ”„ Version History

  • v1.1.3 - Added app crash feature when disabled
  • v1.1.0 - Removed FCM dependencies, app control only
  • v1.0.0 - Initial release with FCM support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Support

๐Ÿ’– Contributing

We welcome contributions! Please read our Contributing Guide for details.


โš ๏ธ Important: This package will crash your app when disabled by server. This is intentional behavior for security and control purposes.

Libraries

firebase_fcm_token