推送功能开发
This commit is contained in:
parent
9a50ca2fdc
commit
53dff92edf
@ -9,6 +9,9 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1B384A992DC1CFE800F5B1A2 /* FacebookCore in Frameworks */ = {isa = PBXBuildFile; productRef = 1B384A982DC1CFE800F5B1A2 /* FacebookCore */; };
|
||||
1B384A9B2DC1CFE800F5B1A2 /* FacebookLogin in Frameworks */ = {isa = PBXBuildFile; productRef = 1B384A9A2DC1CFE800F5B1A2 /* FacebookLogin */; };
|
||||
1BF22FD12DC2169B0082429A /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 1BF22FD02DC2169B0082429A /* FirebaseAnalytics */; };
|
||||
1BF22FD32DC2169B0082429A /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = 1BF22FD22DC2169B0082429A /* FirebaseCore */; };
|
||||
1BF22FD52DC2169B0082429A /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 1BF22FD42DC2169B0082429A /* FirebaseMessaging */; };
|
||||
91D08C5AEAE459A3B8EA48C6 /* Pods_MoviaBox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A81436A54285C9EE97EEBC50 /* Pods_MoviaBox.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -47,8 +50,11 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1BF22FD52DC2169B0082429A /* FirebaseMessaging in Frameworks */,
|
||||
91D08C5AEAE459A3B8EA48C6 /* Pods_MoviaBox.framework in Frameworks */,
|
||||
1BF22FD32DC2169B0082429A /* FirebaseCore in Frameworks */,
|
||||
1B384A992DC1CFE800F5B1A2 /* FacebookCore in Frameworks */,
|
||||
1BF22FD12DC2169B0082429A /* FirebaseAnalytics in Frameworks */,
|
||||
1B384A9B2DC1CFE800F5B1A2 /* FacebookLogin in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -144,6 +150,7 @@
|
||||
minimizedProjectReferenceProxies = 1;
|
||||
packageReferences = (
|
||||
1B384A972DC1CFE800F5B1A2 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */,
|
||||
1BF22FCF2DC2169B0082429A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
|
||||
);
|
||||
preferredProjectObjectVersion = 77;
|
||||
productRefGroup = 1DBC405A2DA4EDFC0093FCB0 /* Products */;
|
||||
@ -461,6 +468,14 @@
|
||||
minimumVersion = 14.1.0;
|
||||
};
|
||||
};
|
||||
1BF22FCF2DC2169B0082429A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 11.12.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
@ -474,6 +489,21 @@
|
||||
package = 1B384A972DC1CFE800F5B1A2 /* XCRemoteSwiftPackageReference "facebook-ios-sdk" */;
|
||||
productName = FacebookLogin;
|
||||
};
|
||||
1BF22FD02DC2169B0082429A /* FirebaseAnalytics */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 1BF22FCF2DC2169B0082429A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
|
||||
productName = FirebaseAnalytics;
|
||||
};
|
||||
1BF22FD22DC2169B0082429A /* FirebaseCore */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 1BF22FCF2DC2169B0082429A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
|
||||
productName = FirebaseCore;
|
||||
};
|
||||
1BF22FD42DC2169B0082429A /* FirebaseMessaging */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 1BF22FCF2DC2169B0082429A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
|
||||
productName = FirebaseMessaging;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 1DBC40512DA4EDFC0093FCB0 /* Project object */;
|
||||
|
@ -1,6 +1,24 @@
|
||||
{
|
||||
"originHash" : "ca3cf5f8f83d297b47d2cb0edff3e06f294951e2e06fa55cfc82831103499b2a",
|
||||
"originHash" : "356668427da72005d8cb60963e877385296f1863605fc5a20d1f75f2cec3b22c",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "abseil-cpp-binary",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git",
|
||||
"state" : {
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
|
||||
"version" : "1.2024072200.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "app-check",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/app-check.git",
|
||||
"state" : {
|
||||
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5",
|
||||
"version" : "11.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "facebook-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
@ -9,6 +27,105 @@
|
||||
"revision" : "c19607d535864533523d1f437c84035e5fb101cf",
|
||||
"version" : "14.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "firebase-ios-sdk",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk",
|
||||
"state" : {
|
||||
"revision" : "fbd463894af94d90eb4d6a4e54080459a8179519",
|
||||
"version" : "11.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googleappmeasurement",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git",
|
||||
"state" : {
|
||||
"revision" : "f7460ea630bddf172115c28493ae8b3798d95ce3",
|
||||
"version" : "11.12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googledatatransport",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleDataTransport.git",
|
||||
"state" : {
|
||||
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
|
||||
"version" : "10.1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "googleutilities",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/GoogleUtilities.git",
|
||||
"state" : {
|
||||
"revision" : "53156c7ec267db846e6b64c9f4c4e31ba4cf75eb",
|
||||
"version" : "8.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "grpc-binary",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/grpc-binary.git",
|
||||
"state" : {
|
||||
"revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71",
|
||||
"version" : "1.69.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "gtm-session-fetcher",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/gtm-session-fetcher.git",
|
||||
"state" : {
|
||||
"revision" : "4d70340d55d7d07cc2fdf8e8125c4c126c1d5f35",
|
||||
"version" : "4.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "interop-ios-for-google-sdks",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
|
||||
"state" : {
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
|
||||
"version" : "101.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "leveldb",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/leveldb.git",
|
||||
"state" : {
|
||||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
|
||||
"version" : "1.22.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "nanopb",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/firebase/nanopb.git",
|
||||
"state" : {
|
||||
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
|
||||
"version" : "2.30910.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "promises",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/google/promises.git",
|
||||
"state" : {
|
||||
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
|
||||
"version" : "2.4.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-protobuf",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-protobuf.git",
|
||||
"state" : {
|
||||
"revision" : "d72aed98f8253ec1aa9ea1141e28150f408cf17f",
|
||||
"version" : "1.29.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
|
62
MoviaBox/AppDelegate/AppDelegate+APNS.swift
Normal file
62
MoviaBox/AppDelegate/AppDelegate+APNS.swift
Normal file
@ -0,0 +1,62 @@
|
||||
//
|
||||
// AppDelegate+APNS.swift
|
||||
// MoviaBox
|
||||
//
|
||||
// Created by 佳尔 on 2025/4/30.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import FirebaseMessaging
|
||||
import FirebaseCore
|
||||
|
||||
extension AppDelegate {
|
||||
|
||||
func registerAPNS() {
|
||||
FirebaseApp.configure()
|
||||
Messaging.messaging().delegate = self
|
||||
|
||||
let center = UNUserNotificationCenter.current()
|
||||
center.delegate = self
|
||||
|
||||
center.requestAuthorization(options: [.badge, .sound, .alert]) { grant, error in
|
||||
if grant {
|
||||
// SPRewardsAPI.requestUploadOpenNotify(completer: nil)
|
||||
}
|
||||
}
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate: UNUserNotificationCenterDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
||||
Messaging.messaging().apnsToken = deviceToken
|
||||
}
|
||||
///APP处于前台是接收通知消息
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||
completionHandler([.badge, .alert])
|
||||
}
|
||||
|
||||
///点击通知消息进入app
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MARK: -------------- MessagingDelegate --------------
|
||||
extension AppDelegate: MessagingDelegate {
|
||||
|
||||
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
||||
if let token = fcmToken {
|
||||
SPApnsAPI.requestUploadDeviceToken(token: token)
|
||||
}
|
||||
|
||||
let dataDict: [String: String] = ["token": fcmToken ?? ""]
|
||||
NotificationCenter.default.post(
|
||||
name: Notification.Name("FCMToken"),
|
||||
object: nil,
|
||||
userInfo: dataDict
|
||||
)
|
||||
}
|
||||
}
|
@ -9,39 +9,6 @@ import UIKit
|
||||
import FacebookCore
|
||||
|
||||
|
||||
extension AppDelegate {
|
||||
|
||||
func registerAPNS() {
|
||||
let center = UNUserNotificationCenter.current()
|
||||
center.delegate = self
|
||||
|
||||
center.requestAuthorization(options: [.badge, .sound, .alert]) { grant, error in
|
||||
if grant {
|
||||
// SPRewardsAPI.requestUploadOpenNotify(completer: nil)
|
||||
}
|
||||
}
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate: UNUserNotificationCenterDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
||||
// NIMSDK.shared().updateApnsToken(deviceToken)
|
||||
}
|
||||
///APP处于前台是接收通知消息
|
||||
// func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||
// completionHandler([.badge])
|
||||
// }
|
||||
|
||||
///点击通知消息进入app
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
extension SceneDelegate {
|
||||
|
||||
///URL打开APP
|
||||
|
21
MoviaBox/Base/Networking/API/SPApnsAPI.swift
Normal file
21
MoviaBox/Base/Networking/API/SPApnsAPI.swift
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// SPApnsAPI.swift
|
||||
// MoviaBox
|
||||
//
|
||||
// Created by 佳尔 on 2025/4/30.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SPApnsAPI: NSObject {
|
||||
static func requestUploadDeviceToken(token: String) {
|
||||
var param = SPNetworkParameters(path: "/customer/firebaseToken")
|
||||
param.parameters = ["fcm_token": token]
|
||||
param.isToast = false
|
||||
|
||||
SPNetwork.request(parameters: param) { (response: SPNetworkResponse<String>) in
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
|
30
MoviaBox/Source/GoogleService-Info.plist
Normal file
30
MoviaBox/Source/GoogleService-Info.plist
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyAT78NBZpoE2kazUeiWOBKuQNczOEtPPbU</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>157639867903</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>com.thimratv.app</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>movia-c4ef0</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>movia-c4ef0.firebasestorage.app</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:157639867903:ios:63bd57e22b7c906450fbca</string>
|
||||
</dict>
|
||||
</plist>
|
@ -16,16 +16,14 @@
|
||||
</dict>
|
||||
<dict/>
|
||||
</array>
|
||||
<key>FacebookAdvertiserIDCollectionEnabled</key>
|
||||
<true/>
|
||||
<key>FacebookAppID</key>
|
||||
<string>1228062532660582</string>
|
||||
<key>FacebookAutoLogAppEventsEnabled</key>
|
||||
<true/>
|
||||
<key>FacebookClientToken</key>
|
||||
<string>ecc9787c931b242fa912481c41b39bb6</string>
|
||||
<key>FacebookDisplayName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>FirebaseAppDelegateProxyEnabled</key>
|
||||
<false/>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
|
Loading…
x
Reference in New Issue
Block a user