...
Bir Firebase projesi oluşturun. Size verilen Google-services.json dosyasını
android/app
klasörü altına kopyalayın. Örnek kullanımAlttaki satırı
android/build.gradle
dosyanızın iki repositories bölümüne de ekleyin.Code Block maven {url 'http://developer.huawei.com/repo/'}
android/build.gradle
dosyanızın dependencies bölümüne aşağıdaki satırları ekleyin. Örnek kullanımCode Block language java classpath 'com.google.gms:google-services:4.3.3' classpath 'com.huawei.agconnect:agcp:1.2.1.301'
minSdkVersion
21 olarak ayarlayınandroid/app/build.gradle
dosyanızın en altına aşağıdaki satırları ekleyin. Örnek kullanımCode Block language java apply plugin: 'com.google.gms.google-services' apply plugin: 'com.huawei.agconnect'
android/app/build.gradle
dosyanızdadefaultConfig
bölümüne alttaki satırı ekleyinCode Block multiDexEnabled true
...
Yüklü uygulamaları raporlamak istiyorsanız alttaki kodu javascript bölümünde çalıştırın.
Code Block language js await visilabsApi.sendTheListOfAppsInstalled()
Ayrıca alttaki yöntemlerden birini seçipAndroidManifest.xml
dosyanıza ekleyin.
Option 1Code Block language xml <manifest package="com.example.myApp"> <queries> <package android:name="com.example.app1" /> <package android:name="com.example.app2" /> </queries> </manifest>
Option 2
Code Block <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" ignore="QueryAllPackagesPermission" />
...
AppDelegate.h
dosyanızdaki @interface ile başlayan satıra UNUserNotificationCenterDelegate parametresini ekleyin. Son hali alttaki gibi olmalı. Örnek kullanım
Klasik React Native projelerindeCode Block @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
Expo projelerinde
Code Block language objective-c @interface AppDelegate : UMAppDelegateWrapper <RCTBridgeDelegate, EXUpdatesAppControllerDelegate, UNUserNotificationCenterDelegate>
AppDelegate.m
dosyanıza alttaki satırları ekleyin. Örnek kullanımCode Block language objective-c #import "RelatedDigitalPushModule.h" #import <UserNotifications/UserNotifications.h>
AppDelegate.m
dosyanızdadidFinishLaunchingWithOptions
methodunun içerisindekireturn
ifadesinin hemen üzerine alttaki satırları ekleyin. Örnek kullanımCode Block language objective-c UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self;
AppDelegate.m
dosyanıza alttaki methodları ekleyin. Örnek kullanımCode Block language objective-c - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RelatedDigitalPushModule didRegisterUserNotificationSettings:notificationSettings]; } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RelatedDigitalPushModule didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RelatedDigitalPushModule didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; } - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RelatedDigitalPushModule didFailToRegisterForRemoteNotificationsWithError:error]; } -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); }
AppDelegate.m
dosyasındakididFinishLaunchingWithOptions
fonksiyonununun return ifadesinden hemen öncesine alttaki kodu ekleyin.
Not: In App ve Geofence özelliklerinin aktif olması içinInAppNotificationsEnabled
vegeofenceEnabled
parametreleritrue
olmalıdır.Code Block language objective-c [RelatedDigitalPushModule initVisilabs:@"organization_id" profileId:@"profile_id" dataSource:@"datasource" inAppNotificationsEnabled:true requestTimeoutSeconds:30 geofenceEnabled:true maxGeofenceCount:20];
SDK Swift kodu içerdiğinden ve xcode her hedefte en az bir boş swift dosyası gerektirdiğinden projenizin ios dizinine boş bir swift dosyası ekleyin.
Empty.swift
iOS 14 ve sonraki sürümlerde AdvertisingTrackingID'yi kullanabilmek için
Info.plist
dosyanızaNSUserTrackingUsageDescription
ekleyin.Eğer
_swift_getFunctionReplacement
veya herhangi bir swift hatasından dolayı sorun yaşarsanız, projenizinLibrary Search Paths
altındaki$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME
satırını kaldırın.Push bildirimleri kullanacaksanız proje hedefinizin
Build Phases
->Copy Bundle Resources
bölümüne aşağıdaki satırları ekleyin.Create folder references
seçeneğini seçin.Code Block Pods/VisilabsIOS/VisilabsIOS/ClassesSources/TargetingAction/InAppNotification/Views/VisilabsMiniNotificationViewController.xib Pods/VisilabsIOS/VisilabsIOS/ClassesSources/TargetingAction/InAppNotification/Views/VisilabsFullNotificationViewController.xib
Görsel veya video gibi zengin içerikli push bildirim özelliklerini etkinleştirmek için alttaki adımları uygulayın.
1- Projenize Targets altındanNotification Service Extension
ekleyin ve isminiRelatedDigitalNotificationService
olarak değiştirin. Ardından bu hizmetin hedef iOS sürümünü 10.0 olarak değiştirin. Örnek kullanım
2- Yeni eklenmiş olanNotificationService.m
dosyasının içerisini alttakilerle değiştirin.
Örnek kullanımCode Block language objective-c #import "NotificationService.h" #import "RelatedDigitalNotificationService.h" @interface NotificationService () @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent; @end @implementation NotificationService - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy]; [RelatedDigitalNotificationService didReceiveNotificationRequest:self.bestAttemptContent withContentHandler:self.contentHandler]; } - (void)serviceExtensionTimeWillExpire { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. [RelatedDigitalNotificationService didReceiveNotificationRequest:self.bestAttemptContent withContentHandler:self.contentHandler]; } @end
3- Podfile dosyanızın kök seviyesine aşağıdaki satırları ekleyin. Örnek kullanımCode Block target 'RelatedDigitalNotificationService' do pod 'react-native-related-digital', :path => '../node_modules/react-native-related-digital' use_native_modules! end # Post Install processing for RelatedDigitalNotificationService causing errors def notification_service_post_install(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' end end end
4- Podfile dosyanızın ana hedef bölümünenotification_service_post_install(installer)
satırını ekleyin, alttaki şekilde gözükmeli. Örnek kullanımCode Block post_install do |installer| notification_service_post_install(installer) # Other post install function calls end
5- Sdk, Swift kodu içerdiğinden ve xcode her hedefte en az bir boş swift dosyası gerektirdiğinden, RelatedDigitalNotificationService hedefinize de boş bir swift dosyası ekleyin.Empty.swift
6- Projenizin ios dizinindepod install
komutunu çalıştırın.Carousel push bildirim için
1- Projenize Targets altındanNotification Content Extension
ekleyin ve isminiRelatedDigitalNotificationContent
olarak değiştirin. Ardından bu hizmetin hedef iOS sürümünü 1011.0 olarak değiştirin.Info.plist
dışındaRelatedDigitalNotificationContent
altına yeni eklenen dosyaları kaldırın. Ardından aşağıdaki içeriğe sahipEMNotificationViewController.swift
dosyasını ekleyin.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 self.view = carouselView } }
2- Yeni eklenenRelatedDigitalNotificationContent/Info.plist
dosyanıza alttaki satırları ekleyin, eğer varsa değiştirin.Code Block <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>UNNotificationExtensionUserInteractionEnabled</key> <true/> <key>UNNotificationExtensionDefaultContentHidden</key> <false/> <key>UNNotificationExtensionCategory</key> <string>carousel</string> <key>UNNotificationExtensionInitialContentSizeRatio</key> <real>1</real> </dict> <key>NSExtensionPrincipalClass</key> <string>RelatedDigitalNotificationContent.EMNotificationViewController</string> <key>NSExtensionPointIdentifier</key> <string>com.apple.usernotifications.content-extension</string> </dict>
3- Podfile dosyanızın kök seviyesine alttaki satırları ekleyin.Code Block target 'RelatedDigitalNotificationContent' do use_native_modules! pod 'Euromsg', '>= 2.0.0' end
4- Xcode'daRelatedDigitalNotificationContent
hedefini seçin. Aşağıdaki dosyalarıBuild Phases
->Copy Bundle Resources
bölümüne ekleyin.Create folder references
seçeneğini seçin.Code Block Pods/Euromsg/Sources/Euromsg/Classes/EMNotificationCarousel/CarouselCell.xib Pods/Euromsg/Sources/Euromsg/Classes/EMNotificationCarousel/EMNotificationCarousel.xib
5- Deployment target değerini ios 10 yapın.Code Block platform :ios, '10.0'
6- Projenizin ios dizinindepod install
komutunu çalıştırın.Geofence konum hizmetleri tanımlamaları
Uygulamanızda konum hizmetlerini etkinleştirmek için öncelikle aşağıdaki anahtarları Info.plist dosyanıza eklemeniz gerekir.
- NSLocationAlwaysAndWhenInUseUsageDescription
- NSLocationWhenInUseUsageDescriptio
Bu izinlerin örnek uygulaması aşağıdaki gibidir:Code Block <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>We need access to your location for better user experience.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>We need access to your location for better user experience.</string>
Ayrıca bölgeleri izlemek, bölge listesini yenilemek ve push bildirimlerini almak için Info.plist dosyanızda UIBackgroundModes altına aşağıdaki anahtarları eklemeniz gerekir.Code Block <array> <string>fetch</string> <string>location</string> <string>remote-notification</string> </array>
...