My app does not appear in the iOS notification center - Appcelerator - ios

I'm having serious headaches with push for iOS with titanium appcelerator.
I generated several versions in testflight, but none of them appear in the iOS notification center, however, when I swipe directly into the device, it works normally on my iPad Mini.
I am currently using these settings:
Operating System
Name = Mac OS X
Version = 10.12
Architecture = 64bit
# CPUs = 4
Memory = 4294967296
Node.js
Node.js Version = 4.6.0
npm Version = 2.15.9
Titanium CLI
CLI Version = 5.0.9
Titanium SDK
SDK Version = 5.5.1.GA
SDK Path = /Users/silvio/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA
Target Platform = iphone
Xcode Version: 8.2 (8C38)
My code in Alloy.js:
if (Ti.Platform.name === 'android') {
// set android-only options
var pnOptions = {
senderId: 'xxxx', // It's the same as your project id
notificationSettings: {
sound: 'mysound.mp3', // Place soudn file in platform/android/res/raw/mysound.mp3
smallIcon: 'appicon.png', // Place icon in platform/android/res/drawable/notification_icon.png
largeIcon: 'appicon.png', // Same
vibrate: true, // Whether the phone should vibrate
insistent: true, // Whether the notification should be insistent
group: 'Edufy', // Name of group to group similar notifications together
localOnly: false, // Whether this notification should be bridged to other devices
priority: 2 // Notification priority, from -2 to 2
}
};
} else { // set ios-only options.
// Sets interactive notifications as well if iOS8 and above. Interactive notifications is optional.
if (parseInt(Ti.Platform.version.split(".")[0], 10) >= 8) {
var thumbUpAction = Ti.App.iOS.createUserNotificationAction({
identifier: "THUMBUP_IDENTIFIER",
title: "Aceitar",
activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive: false,
authenticationRequired: false
});
var thumbDownAction = Ti.App.iOS.createUserNotificationAction({
identifier: "THUMBDOWN_IDENTIFIER",
title: "Regeitar",
activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive: false,
authenticationRequired: false
});
var thumbUpDownCategory = Ti.App.iOS.createUserNotificationCategory({
identifier: "THUMBUPDOWN_CATEGORY",
// The following actions will be displayed for an alert dialog
actionsForDefaultContext: [thumbUpAction, thumbDownAction],
// The following actions will be displayed for all other notifications
actionsForMinimalContext: [thumbUpAction, thumbDownAction]
});
var pnOptions = {
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND],
categories: [thumbUpDownCategory]
};
} else { //No support for interactive notifications, omit categories
var pnOptions = {
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND]
};
}
}
// set cross-platform event
var onReceive = function(event) {};
// Create instance with base url
var tiPush = require('ti-push-notification').init({
backendUrl: "http://xxxx.com.br/painel/ws/push_test.php"
});
// register this device
tiPush.registerDevice({
pnOptions: pnOptions,
onReceive: onReceive,
extraOptions: {
action: 'register',
user_id: 123
}
});
My certificates in the apple store are all valid, as in the prints below:
Push Notifications Enabled:
Certificates:
Prov Profiles:
Also, I tried adding the Entitlements.plist in these locations:
Project / Entitlements.plist
Project / app / Entitlements.plist
Project / app / platform / ios / Entitlements.plist
Project / app / platform / ios / .plist
I also added the lines from within the tag to tiapp.xml, but it did not work ... below the Entitlements.plist code:
<?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>aps-environment</key>
<string>development</string> <!-- Either development or production -->
<key>application-identifier</key>
<string>xxxx.com.colegiokennedy</string>
<key>keychain-access-groups</key>
<array>
<string>xxx.com.colegiokennedy</string>
</array>
</dict>
</plist>
I've also tried changing the development environment to production, but it did not work too.

You can try including Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE.
Make sure that in your iOS device, go to Settings -> Notifications -> Your_App -> Show in Notification Centre is selected. You can check that what kind of settings are on/off for your app's notifications.

Related

Flutter / Swift Compiler Error (Xcode): Cannot find 'ExternalLinkAccount' in scope

Since 12th october 2022, reader's app with external account management/purchase must have to declare a new entitlement.
External Link Account
Enable qualifying apps to link to an external website for account creation or management.
https://developer.apple.com/documentation/storekit/external_link_account
I can't build because :
Swift Compiler Error (Xcode): Cannot find 'ExternalLinkAccount' in scope
Configure the SKExternalLinkAccount property list key.
<plist>
<dict>
<key>SKExternalLinkAccount</key>
<dict>
<key>*</key>
<string>https://example.com</string>
<key>jp</key>
<string>https://example.com/jp</string>
</dict>
</dict>
</plist>
Runner plist
<key>com.apple.developer.storekit.external-link.account</key>
<true/>
Runner entitlement
<plist>
<dict>
<key>com.apple.developer.storekit.external-link.account</key>
<true/>
</dict>
</plist>
ios build (with flutter run) :
Swift Compiler Error (Xcode): Cannot find 'ExternalLinkAccount' in scope
My code in a custom swift file (called with a platform specific call)
import SwiftUI
struct ExternalLinkAccountModal: View {
var body: some View {
Text("Hello, world!")
.padding()
.onAppear {
Task {
await executeTask()
}
}
}
}
struct ExternalLinkAccountModal_Previews: PreviewProvider {
static var previews: some View {
ExternalLinkAccountModal(onConfirm: nil, onCancel: nil)
.previewDevice("iPhone 13")
.previewInterfaceOrientation(.portrait)
}
}
func executeTask() async {
let basicTask = Task {
if await ExternalLinkAccount.canOpen {
do {
try await ExternalLinkAccount.open()
} catch {
print("ExternalLinkAccount.open() error \(error)")
}
}
}
}
Provisioning profile
My provisioning profile is well configured and accepted by Apple Developper :
Associated Domains, External Link Account, In-App Purchase, Push Notifications
Can you help to fix this ?
I'm using osx Ventura and ios16 platform for developping.

IOS 13 doesn't play a notification sound using FirebasePushNotificationPlugin

I use Firebase to push notifications to the users at a certain time. They receive the notification but no alert sound is played. In the settings, the allow sound/notifications are turned on and other IOS13 and other apps play sound.
Version Number of FirebasePushNotificationPlugin Plugin: 3.3.10
Device Tested On: iphone X, OS: 13.4.1
Simulator Tested On: N/A (simulators don't receive notifications)
Version of VS: VS for Mac Community, 8.6.6 (build 11)
Version of Xamarin: Xamarin.IOS 13.18.2.1, Xamarin.Forms v4.6.0.847
AppDelegate.cs:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
bool fbaseStarted = false;
try
{
// This method does all the UNUserNotificationCenter.Current.RequestAuthorization() code so we don't have to.
FirebasePushNotificationManager.Initialize(options, true);
fbaseStarted = true;
}
catch
{ }
LoadApplication(new App());
if (!fbaseStarted)
{
try
{
FirebasePushNotificationManager.Initialize(options, true);
}
catch { }
}
FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Badge | UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound;
}
Within one of the pages of my code, I subscribe a list of tags (please note that I unsubscribe because the first time the code runs it fails silently if the notifications aren't approved - resulting in the model thinking the notifications was subscribed when it wasn't):
CrossFirebasePushNotification.Current.UnsubscribeAll();
CrossFirebasePushNotification.Current.Subscribe(Constants.NotificationTagsArray);
I keep coming across payload json solutions but unless I am wrong, I don't think that applies to me as I am using Xamarin and the FirebasePushNotificationPlugin. Is there any additional permissions that were added in ios 13 for playing notifications with sound that I have missed?
I have also posted here: https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/348 but nobody has been able to assist me yet.
Thanks
The issue actually lies with the sending of the notifications nothing to do with the Xamarin App. The issue resided in the services that sends the notifications to firebase (to then be sent out to the phones).
In the service we were sending a FirebaseNet.Messaging.Message() to the phones:
Message FireBasemessage = new Message()
{
To = "/topics/" + PushNote.Tag,
TimeToLive = 86400,
Priority = MessagePriority.high,
ContentAvailable = true,
Notification = new AndroidNotification()
{
Tag = "/topics/" + PushNote.Tag,
Body = enhancedMessage,
Title = xtitle,
}
,
Data = new Dictionary<string, string>
{
{ "param", PushNote.Tag },
{ "text", enhancedMessage}
}
};
In the AndroidNotification() object required Sound = "default" to be added for it to work. Please note that this works for both Android and IOS notifications despite the fact it is an AndroidNotification object.

Xamarin IOS Push Killed app

Push =>
{{
aps = {
alert = {
"loc-args" = (
);
"loc-key" = "new_chat";
};
"content-available" = 1;
id = 3;
message = Aaa;
sound = default;
subject = "new_chat";
type = chat;
};
}}
When the application is killed and I receive a push notification it is shown with the text "new_chat". How can I change it to another text?
Assuming you are targeting iOS 10+, you can add a Notification Services extension app (UNNotificationServiceExtension) to your app bundle.
modifies the content of a remote notification before it is delivered to the user.
In the DidReceiveNotificationRequest override, extract your content from the UNNotificationRequest and modify it and return it via the contentHandler provided.
Required reading to understand how/when the extension is used:
Modifying Content in Newly Delivered Notifications
Also:
Xamarin Docs: iOS Extensions in Xamarin.iOS
Apple docs: UNNotificationServiceExtension

How can I automatically install a custom CA root certificate on my iOS simulators for testing?

My iOS app communicates with my backend server which has a valid certificate. During development my iOS app is configured to communicate with my internal test server which has a certificate signed by my self signed root certificate.
Prior to iOS 11 I could configure my app to trust connections signed by my self signed root using instructions laid out here: https://developer.apple.com/library/content/technotes/tn2232/_index.html#//apple_ref/doc/uid/DTS40012884-CH1-SECCUSTOMCERT
However in iOS 11 it is no longer possible for an app to bypass ATS without creating an ATS exception int the info.plist. This thread includes some explanation from Apple: https://forums.developer.apple.com/thread/89694
So now in iOS how can I install my custom CA root on all my iOS simulators in some kind of automated way?
Since iOS 11 support multi-app UI testing I created a UI test that causes the iOS system to install my custom CA's root using Safari and the Settings app. The source for the UI test is as follows:
import XCTest
class InstallRootCerts: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
}
func testInstallTestingRootCertOnDevice() {
// Set test time env var ROOT_CA to point to your custom CA's .cer file.
let cert = ProcessInfo.processInfo.environment["ROOT_CA"]
// Set test time env var ROOT_CA_NAME to contain the name of your CA.
let caName = ProcessInfo.processInfo.environment["ROOT_CA_NAME"]
let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
let settings = XCUIApplication(bundleIdentifier: "com.apple.Preferences")
safari.activate()
XCTAssertNotNil(cert)
let certUrl = "file://\(cert!)"
if safari.otherElements["URL"].exists {
safari.otherElements["URL"].tap()
}
let addressBar = safari.textFields["URL"]
addressBar.typeText(certUrl)
safari.buttons["Go"].tap()
safari.buttons["Allow"].tap()
XCTAssertTrue( settings.wait(for: .runningForeground, timeout: 30) )
if !settings.staticTexts["Verified"].exists {
settings.buttons["Install"].tap()
settings.buttons["Install"].tap()
settings.sheets.buttons["Install"].tap()
}
// Now trust the root certificate
settings.buttons["Cancel"].tap()
XCTAssertTrue( safari.wait(for: .runningForeground, timeout: 120) )
settings.activate()
XCTAssertTrue( settings.wait(for: .runningForeground, timeout: 120) )
settings.buttons["General"].tap()
settings.cells["About"].tap()
settings.cells["Certificate Trust Settings"].tap()
let cell = settings.cells.containing(.staticText, identifier: caName)
let toggle = cell.switches.firstMatch
if toggle.value as? String != "1" {
toggle.tap()
settings.buttons["Continue"].tap()
}
}
}
This test case only works on simulators running iOS 11.0. I think it could be made to work with actual devices if you put the .cer file on a web server and opened it over http.
This test case can then be run as a Bot on your Xcode server or you can run it on any simulator locally to set it up. This is a hack I know.

How to display GameCenter leaderboard on tvOS?

I think I followed all the required steps to support leaderboards in my game (and they work just fine on iOS), however on tvOS it is not possible to configure the GKGameCenterViewController to show a specific leaderboard, the LeaderboardIdentifier property is simply missing (just like the ViewState):
var leaderboardController = new GKGameCenterViewController ();
// Unavailable on tvOS
/*
leaderboardController.ViewState = GKGameCenterViewControllerState.Default;
leaderboardController.LeaderboardIdentifier = "myLeaderboardId";
*/
leaderboardController.Finished += (sender, e) =>
{
leaderboardController.DismissViewController (true, null);
}
PresentViewController (leaderboardController, true, null);
Instead of using these properties, I followed the instructions here. I notice that this will generate a GKGameCenterContent.plist file in the final app bundle. I double checked the content:
<?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>GKLeaderboards</key>
<array>
<dict>
<key>identifier</key>
<string>myLeaderboardId</string>
<key>onDemandResourcesTag</key>
<string>com.apple.gamecenter.Leaderboard</string>
<key>posterImageName</key>
<string>Leaderboard/Poster</string>
</dict>
</array>
</dict>
</plist>
This looks absolutely correct, also the images are of course in the bundle. Still, using the code above to show the game center controller will only give me the achievements screen and nothing else.
You have to add a leaderboard to Assets.xassets. There you can enter the identifier:
The code to show the leaderboard:
#IBAction func openLeaderboard(sender: AnyObject) {
let gcViewController = GKGameCenterViewController()
gcViewController.gameCenterDelegate = self
self.presentViewController(gcViewController, animated: true, completion: nil)
}

Resources