...
Xcode'da yeni bir Notification Content Extension hedefi ekleyin ve bunu NotificationContent olarak adlandırın.
Pod dosyanıza aşağıdaki bölümü ekleyin ve ardından
pod install
çalıştırın.Code Block target 'NotificationContent' do use_frameworks! pod 'Euromsg' end
NotificationContent hedefinin dağıtım hedefini iOS 11 olarak ayarlayın.
MainInterface.storyboard ve NotificationContent.swift dosyalarını silin. Ardından, NotificationContent klasörü altında EMNotificationViewController.swift adlı bir Swift dosyası oluşturun.
EMNotificationViewController.Swift dosya içeriğini aşağıdaki kodla değiştirin.
Code Block language swift import UIKit import UserNotifications import UserNotificationsUI import Euromsg @available(iOS 10.0, *) @objc(EMNotificationViewController) class EMNotificationViewController: UIViewController, UNNotificationContentExtension { let appUrl = URL(string: "euromsgExample://") let carouselView = EMNotificationCarousel.initView() var completion: ((_ url: URL?, _ userInfo: [AnyHashable: Any]?) -> Void)? func didReceive(_ notification: UNNotification) { carouselView.didReceive(notification) } func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { carouselView.didReceive(response, completionHandler: completion) } override func loadView() { completion = { [weak self] url, userInfo in if let url = url { self?.extensionContext?.open(url) if url.scheme != self?.appUrl?.scheme, let userInfo = userInfo { Euromsg.handlePush(pushDictionary: userInfo) } } else if let url = self?.appUrl { self?.extensionContext?.open(url) } } carouselView.completion = completion //Add if you want to track which element has been selected carouselView.delegate = self self.view = carouselView } } /** Add if you want to track which carousel element has been selected */ extension EMNotificationViewController: CarouselDelegate { func selectedItem(_ element: EMMessage.Element) { //Add your work... print("Selected element is => \(element)") } }
NotificationContent/Info.plist
'inize aşağıdaki bölümü ekleyin.Code Block language xml <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>UNNotificationExtensionCategory</key> <string>carousel</string> <key>UNNotificationExtensionDefaultContentHidden</key> <false /> <key>UNNotificationExtensionInitialContentSizeRatio</key> <real>1</real> <key>UNNotificationExtensionUserInteractionEnabled</key> <true /> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.usernotifications.content-extension</string> <key>NSExtensionPrincipalClass</key> <string>NotificationContent.EMNotificationViewController</string> </dict>
Geofencing
Kullanıcılarınızı lokasyon bazlı takip edip önceden belirlediğiniz alanlara girdiklerinde push bildirim atabilirsiniz. Bunu kullanmak için alttaki adımları takip edin.
iOS
Xcode'da, Info.plist dosyasına
NSLocationAlwaysAndWhenInUseUsageDescription
veNSLocationWhenInUseUsageDescription
anahtarlarını ekleyin.Xcode'da, background modlarından Background fetch ve Location updates modlarını etkinleştirin.
Eklentiyi başlatırken
geofenceEnabled
değerinitrue
olarak ayarlayın. AyrıcamaxGeofenceCount
parametresi için bir sayı sağlayın (maks. 20 desteklenir).
Android
AndroidManifest.xml
dosyanıza aşağıdaki izinleri ekleyinCode Block language xml <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
AndroidManifest.xml
dosyanıza aşağıdaki hizmeti ve alıcıları ekleyinCode Block language xml <service android:name="com.visilabs.android.gps.geofence.GeofenceTransitionsIntentService" android:enabled="true" android:permission="android.permission.BIND_JOB_SERVICE" /> <receiver android:name="com.visilabs.android.gps.geofence.VisilabsAlarm" android:exported="false"/> <receiver android:name="com.visilabs.android.gps.geofence.GeofenceBroadcastReceiver" android:enabled="true" android:exported="true"/>
Set Push Permit
Uygulama için push bildirimlerini etkinleştirmek veya devre dışı bırakmak için yalnızca setNotificationPermission
yöntemini çağırabilirsiniz.
...