Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation of MTN PIN USSD #107

Merged
merged 13 commits into from
Mar 26, 2024
Prev Previous commit
Next Next commit
Fixed Deprecated CodePin API
  • Loading branch information
cedricbahirwe committed Mar 25, 2024
commit 431d65de54aefdec009988e378b32a894edb64ab
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "DEV - Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
11 changes: 8 additions & 3 deletions Dialer/Dialer/Models/PurchaseDetailModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ extension PurchaseDetailModel {
return "\(prefixCode)\(amount)*PIN#"
}

func getFullUSSDCode(with pinCode: CodePin?) -> String {
@available(*, deprecated, renamed: "getFullUSSDCode()", message: "MTN disabled the ability to directly dial airtime USSD that includes Momo PIN.")
private func getFullUSSDCode(with pinCode: CodePin?) -> String {
let pin: String
if let pinCode, pinCode.digits >= 5 {
pin = pinCode.asString
Expand All @@ -38,13 +39,17 @@ extension PurchaseDetailModel {
}
}

func getFullUSSDCode() -> String {
return "\(prefixCode)\(amount)#"
}


/// Used on the `PuchaseDetailView` to dial, save code, save pin.
/// - Parameters:
/// - purchase: the purchase to take the fullCode from.
func dialCode(pinCode: CodePin? = nil) async throws {
func dialCode() async throws {

let newUrl = getFullUSSDCode(with: pinCode)
let newUrl = getFullUSSDCode()

if let telUrl = URL(string: "tel://\(newUrl)") {
try await DialService.dial(telUrl)
Expand Down
2 changes: 1 addition & 1 deletion Dialer/Dialer/Models/TransactionModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Transaction: Identifiable {
var number: String
var type: TransactionType

var trailingCode: String {
private var trailingCode: String {
// Need strategy to deal with country code
number.replacingOccurrences(of: " ", with: "") + "*" + amount
}
Expand Down
4 changes: 2 additions & 2 deletions Dialer/Dialer/View Models/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class MainViewModel: ObservableObject {
/// - purchase: the purchase to take the fullCode from.
private func dialCode(from purchase: PurchaseDetailModel) async throws {

let newUrl = purchase.getFullUSSDCode(with: pinCode)
let newUrl = purchase.getFullUSSDCode()

if let telUrl = URL(string: "tel://\(newUrl)") {
try await DialService.dial(telUrl)
Expand All @@ -91,7 +91,7 @@ final class MainViewModel: ObservableObject {
}

func getPurchaseDetailUSSDCode() -> String {
purchaseDetail.getFullUSSDCode(with: pinCode)
purchaseDetail.getFullUSSDCode()
}

/// Perform an independent dial, without storing or tracking.
Expand Down
21 changes: 14 additions & 7 deletions Dialer/Dialer/Views/DashBoardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ struct DashBoardView: View {
}
}
}
PurchaseDetailView(isPresented: $showPurchaseSheet, data: data)
makePurchaseDetailView()
}

}
.sheet(isPresented: isIOS16AndPlus ? $showPurchaseSheet : .constant(false)) {
if #available(iOS 16.0, *) {
PurchaseDetailView(isPresented: $showPurchaseSheet, isIOS16: true, data: data)
.presentationDetents([.medium])
makePurchaseDetailView()
.presentationDetents([.height(400)])
.presentationDragIndicator(.visible)
}
}
.sheet(isPresented: $showWelcomeView) {
Expand Down Expand Up @@ -136,7 +137,16 @@ struct DashBoardView: View {
.trackAppearance(.dashboard)
}

private var gearGradient: some View {
private func makePurchaseDetailView() -> PurchaseDetailView {
PurchaseDetailView(
isPresented: $showPurchaseSheet,
isIOS16: isIOS16AndPlus,
data: data)
}
}

private extension DashBoardView {
var gearGradient: some View {
LinearGradient(gradient: Gradient(colors: [.red, .blue]), startPoint: .topLeading, endPoint: .bottomTrailing)
.frame(width: 30, height: 30)
.mask(
Expand All @@ -146,9 +156,6 @@ struct DashBoardView: View {
)
}

}

extension DashBoardView {
var bottomBarView: some View {
HStack {
if UIApplication.hasSupportForUSSD {
Expand Down
Loading