smsist_flutter 0.1.0 copy "smsist_flutter: ^0.1.0" to clipboard
smsist_flutter: ^0.1.0 copied to clipboard

Official Flutter SDK for sms.ist - Global push notification service. Send notifications without Firebase configuration files.

example/lib/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // ⭐ SADECE BU SATIR! API Key'inizi buraya yazın
  await SmsIst.init(
    apiKey: 'YOUR_API_KEY_HERE', // https://sms.ist'den alın
    enableLogs: true,
  );

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final List<String> _notifications = [];
  String? _deviceToken;

  @override
  void initState() {
    super.initState();
    _setupSmsIst();
  }

  void _setupSmsIst() {
    // Device token'ı al
    setState(() {
      _deviceToken = SmsIst.deviceToken;
    });

    // Bildirimleri dinle
    SmsIst.onNotificationReceived.listen((notification) {
      setState(() {
        _notifications.insert(
          0,
          '${notification.title}\n${notification.body}',
        );
      });

      // Snackbar göster
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text('📩 ${notification.title}'),
          duration: const Duration(seconds: 3),
        ),
      );
    });

    // iOS için permission iste
    _requestPermissions();
  }

  Future<void> _requestPermissions() async {
    final granted = await SmsIst.requestPermissions();
    print('Notification permissions: $granted');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'sms.ist Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('sms.ist Example'),
          backgroundColor: Colors.blue,
        ),
        body: Column(
          children: [
            // Device Token
            Container(
              padding: const EdgeInsets.all(16),
              color: Colors.blue.shade50,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text(
                    'Device Token:',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 16,
                    ),
                  ),
                  const SizedBox(height: 8),
                  Text(
                    _deviceToken ?? 'Loading...',
                    style: const TextStyle(
                      fontSize: 12,
                      fontFamily: 'monospace',
                    ),
                  ),
                ],
              ),
            ),

            const Divider(height: 1),

            // Notifications header
            Container(
              padding: const EdgeInsets.all(16),
              alignment: Alignment.centerLeft,
              child: Text(
                'Notifications (${_notifications.length})',
                style: const TextStyle(
                  fontWeight: FontWeight.bold,
                  fontSize: 18,
                ),
              ),
            ),

            // Notifications list
            Expanded(
              child: _notifications.isEmpty
                  ? const Center(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Icon(
                            Icons.notifications_none,
                            size: 64,
                            color: Colors.grey,
                          ),
                          SizedBox(height: 16),
                          Text(
                            'No notifications yet',
                            style: TextStyle(
                              color: Colors.grey,
                              fontSize: 16,
                            ),
                          ),
                          SizedBox(height: 8),
                          Text(
                            'Send a test notification from\nsms.ist dashboard',
                            textAlign: TextAlign.center,
                            style: TextStyle(
                              color: Colors.grey,
                              fontSize: 14,
                            ),
                          ),
                        ],
                      ),
                    )
                  : ListView.builder(
                      itemCount: _notifications.length,
                      itemBuilder: (context, index) {
                        return ListTile(
                          leading: const CircleAvatar(
                            child: Icon(Icons.notifications),
                          ),
                          title: Text(_notifications[index]),
                          subtitle: Text(
                            'Received: ${DateTime.now().toString().substring(11, 19)}',
                          ),
                        );
                      },
                    ),
            ),
          ],
        ),

        // Floating action button
        floatingActionButton: FloatingActionButton.extended(
          onPressed: () {
            showDialog(
              context: context,
              builder: (context) => AlertDialog(
                title: const Text('How to Send Notification'),
                content: const Text(
                  '1. Go to https://sms.ist\n'
                  '2. Login to dashboard\n'
                  '3. Click "Send Notification"\n'
                  '4. Enter title and message\n'
                  '5. Click Send',
                ),
                actions: [
                  TextButton(
                    onPressed: () => Navigator.pop(context),
                    child: const Text('OK'),
                  ),
                ],
              ),
            );
          },
          icon: const Icon(Icons.help_outline),
          label: const Text('How to Test'),
        ),
      ),
    );
  }
}
0
likes
160
points
8
downloads

Publisher

unverified uploader

Weekly Downloads

Official Flutter SDK for sms.ist - Global push notification service. Send notifications without Firebase configuration files.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, plugin_platform_interface

More

Packages that depend on smsist_flutter

Packages that implement smsist_flutter