Framework7-notifications-iOS

提供:Dev Guides
移動先:案内検索

Framework7-iOSの例

説明

Framework7では、iOSレイアウトでさまざまな種類の通知を使用できます。

次の例は、Framework7でのiOS通知の使用を示しています-

<!DOCTYPE html>
<html class="with-statusbar-overlay">
   <head>
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">
      <title>Notifications</title>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css">
      <link rel="stylesheet" href="custom.css">
   </head>
   <body>
      <div class="views">
         <div class="view view-main">
            <div class="pages navbar-fixed">
               <div data-page="home" class="page">
                  <div class="navbar">
                     <div class="navbar-inner">
                        <div class="center sliding">Notifications</div>
                     </div>
                  </div>
                  <div class="page-content">
                     <div class="content-block">
                        <p><a href="#" class="button notification-default">Default</a></p>
                        <p><a href="#" class="button notification-full">Full-layout notification</a></p>
                        <p><a href="#" class="button notification-custom">Custom image</a></p>
                        <p><a href="#" class="button notification-callback">Callback on close</a></p>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
      <script>
         var myApp = new Framework7();
         var mainView = myApp.addView('.view-main');

         var $$ = Dom7;

         $$('.notification-default').on('click', function () {
            myApp.addNotification({
               title: 'Default notification',
               message: 'This is default notification with title and message'
            });
         });
         $$('.notification-full').on('click', function () {
            myApp.addNotification({
               title: 'Full-layout',
               subtitle: 'Notification subtitle',
               message: 'You have a new mail',
               media: '<i class="icon icon-form-email"></i>'
            });
         });
         $$('.notification-custom').on('click', function () {
            myApp.addNotification({
               title: 'Event',
               subtitle: 'You missed an event at your place..',
               message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                  Aenean ut posuere erat. Aliquam sed molestie risus, quis tincidunt dui.',
                  media: '<img width="44" height="44" style="border-radius:100%" src="/framework7/images/pic2.jpg">'
            });
         });
         $$('.notification-callback').on('click', function () {
            myApp.addNotification({
               title: 'Album',
               subtitle: 'A Wonderful Myth',
               message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                  Aliquam sed molestie risus, quis tincidunt dui.',
                  media: '<img width="44" height="44" style="border-radius:100%" src="/framework7/images/pic.jpg">',
               onClose: function () {
                  myApp.alert('Callback activated. Notification closed');
               }
            });
         });
      </script>
   </body>
</html>

出力

上記のコードがどのように機能するかを確認するために次の手順を実行してみましょう-

  • 上記のHTMLコードを notifications_iOSl ファイルとしてサーバーのルートフォルダーに保存します。
  • このHTMLファイルをhttp://localhost/notifications_iOSlとして開くと、出力は以下のように表示されます。
  • この例では、iOSレイアウトでのデフォルト通知、完全レイアウト通知、カスタムメッセージによる通知など、さまざまなタイプの通知を提供します。